Advertisement
Guest User

Test Container

a guest
Jul 9th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.74 KB | None | 0 0
  1. using Microsoft.VisualStudio.TestWindow.Extensibility;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6.  
  7. namespace TSTestAdapter
  8. {
  9.     public class TSTestContainer : ITestContainer
  10.     {
  11.         private readonly string source;
  12.         private readonly ITestContainerDiscoverer discoverer;
  13.         private readonly DateTime timeStamp;
  14.  
  15.         public TSTestContainer(ITestContainerDiscoverer discoverer, string source)
  16.         {
  17.             this.discoverer = discoverer;
  18.             this.source = source;
  19.             this.timeStamp = GetTimeStamp();
  20.         }
  21.  
  22.         private TSTestContainer(TSTestContainer copy)
  23.             : this(copy.discoverer, copy.Source)
  24.         {
  25.         }
  26.  
  27.         private DateTime GetTimeStamp()
  28.         {
  29.             if (!String.IsNullOrEmpty(this.Source) && File.Exists(this.Source))
  30.             {
  31.                 return File.GetLastWriteTime(this.Source);
  32.             }
  33.             else
  34.             {
  35.                 return DateTime.MinValue;
  36.             }
  37.         }
  38.  
  39.         #region ITestContainer members
  40.  
  41.         public int CompareTo(ITestContainer other)
  42.         {
  43.             var testContainer = other as TSTestContainer;
  44.             if (testContainer == null)
  45.             {
  46.                 return -1;
  47.             }
  48.  
  49.             var result = String.Compare(this.Source, testContainer.Source, StringComparison.OrdinalIgnoreCase);
  50.             if (result != 0)
  51.             {
  52.                 return result;
  53.             }
  54.  
  55.             return this.timeStamp.CompareTo(testContainer.timeStamp);
  56.         }
  57.  
  58.         public IEnumerable<Guid> DebugEngines
  59.         {
  60.             get { return Enumerable.Empty<Guid>(); }
  61.         }
  62.  
  63.         public Microsoft.VisualStudio.TestWindow.Extensibility.Model.IDeploymentData DeployAppContainer()
  64.         {
  65.             return null;
  66.         }
  67.  
  68.         public ITestContainerDiscoverer Discoverer
  69.         {
  70.             get { return this.discoverer; }
  71.         }
  72.  
  73.         public bool IsAppContainerTestContainer
  74.         {
  75.             get { return false; }
  76.         }
  77.  
  78.         public ITestContainer Snapshot()
  79.         {
  80.             return new TSTestContainer(this);
  81.         }
  82.  
  83.         public string Source
  84.         {
  85.             get { return this.source; }
  86.         }
  87.  
  88.         public Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion TargetFramework
  89.         {
  90.             get { return Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion.None; }
  91.         }
  92.  
  93.         public Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture TargetPlatform
  94.         {
  95.             get { return Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture.AnyCPU; }
  96.         }
  97.  
  98.         #endregion
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement