コード例 #1
0
 /// <summary>
 /// Constructor for a test method manager, which handles executing a single test method 
 /// for a unit test provider.
 /// </summary>
 /// <param name="testHarness">The unit test harness object.</param>
 /// <param name="testClass">The test class metadata object.</param>
 /// <param name="testMethod">The test method metadata object.</param>
 /// <param name="instance">The test class instance.</param>
 /// <param name="provider">The unit test provider.</param>
 public TestMethodManager(UnitTestHarness testHarness, ITestClass testClass, ITestMethod testMethod, object instance, IUnitTestProvider provider)
   : base(testHarness, provider)
 {
   _testClass = testClass;
   _testMethod = testMethod;
   _instance = instance;
 }
コード例 #2
0
    public void Run(UnitTestSettings settings)
    {
      // Avoid having the Run method called twice
      if (_harness != null)
      {
        return;
      }

      _harness = settings.TestHarness;
      if (_harness == null)
      {
        throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestSystem_Run_NoTestHarnessInSettings);
      }

      if (settings.TestService == null && !settings.TestServiceSetterCalled)
      {
        SetTestService(settings);
      }

      _harness.Settings = settings;
      _harness.TestHarnessCompleted += (sender, args) => OnTestHarnessCompleted(args);

      if (settings.StartRunImmediately)
      {
        _harness.Run();
      }
    }
コード例 #3
0
 /// <summary>
 /// Constructor for a test method manager, which handles executing a single test method
 /// for a unit test provider.
 /// </summary>
 /// <param name="testHarness">The unit test harness object.</param>
 /// <param name="testClass">The test class metadata object.</param>
 /// <param name="testMethod">The test method metadata object.</param>
 /// <param name="instance">The test class instance.</param>
 /// <param name="provider">The unit test provider.</param>
 public TestMethodManager(UnitTestHarness testHarness, ITestClass testClass, ITestMethod testMethod, object instance, IUnitTestProvider provider)
     : base(testHarness, provider)
 {
     _testClass  = testClass;
     _testMethod = testMethod;
     _instance   = instance;
 }
コード例 #4
0
 /// <summary>
 /// Initializes dispatcher-stack attaching method container work item.
 /// </summary>
 /// <param name="testHarness">Test harness.</param>
 /// <param name="instance">Test instance.</param>
 /// <param name="method">Method reflection object.</param>
 /// <param name="testMethod">Test method metadata.</param>
 /// <param name="granularity">Granularity of test.</param>
 public UnitTestMethodContainer(UnitTestHarness testHarness, object instance, MethodInfo method, ITestMethod testMethod, TestGranularity granularity)
     : base(instance, method, testMethod)
 {
     _granularity = granularity;
     _harness     = testHarness as UnitTestHarness;
     _testMethod  = testMethod;
 }
コード例 #5
0
 /// <summary>
 /// Initializes dispatcher-stack attaching method container work item.
 /// </summary>
 /// <param name="testHarness">Test harness.</param>
 /// <param name="instance">Test instance.</param>
 /// <param name="method">Method reflection object.</param>
 /// <param name="testMethod">Test method metadata.</param>
 /// <param name="granularity">Granularity of test.</param>
 public UnitTestMethodContainer(UnitTestHarness testHarness, object instance, MethodInfo method, ITestMethod testMethod, TestGranularity granularity)
   : base(instance, method, testMethod)
 {
   _granularity = granularity;
   _harness = testHarness as UnitTestHarness;
   _testMethod = testMethod;
 }
コード例 #6
0
 /// <summary>
 /// A container type that handles an entire test class throughout the 
 /// test run.
 /// </summary>
 /// <param name="filter">Test run filter object.</param>
 /// <param name="testHarness">The unit test harness.</param>
 /// <param name="testClass">The test class metadata interface.</param>
 /// <param name="instance">The object instance.</param>
 /// <param name="provider">The unit test provider.</param>
 public TestClassManager(TestRunFilter filter, UnitTestHarness testHarness, ITestClass testClass, object instance, IUnitTestProvider provider)
   : base(testHarness, provider)
 {
   _filter = filter;
   _testClass = testClass;
   _testExecutionQueue = new CompositeWorkItem();
   _instance = instance;
 }
コード例 #7
0
 /// <summary>
 /// Create a new assembly manager, takes in the harness, provider 
 /// reference and actual IAssembly object.
 /// </summary>
 /// <param name="runFilter">The test run filter object.</param>
 /// <param name="testHarness">Harness object.</param>
 /// <param name="provider">The unit test metadata provider.</param>
 /// <param name="testAssembly">The test assembly metadata object.</param>
 public AssemblyManager(TestRunFilter runFilter, UnitTestHarness testHarness, IUnitTestProvider provider, IAssembly testAssembly)
   : base(testHarness, provider)
 {
   _filter = runFilter;
   _assembly = testAssembly;
   _testClasses = new CompositeWorkItem();
   ClassInstances = new TestClassInstanceDictionary();
 }
コード例 #8
0
 /// <summary>
 /// Create a new assembly manager, takes in the harness, provider
 /// reference and actual IAssembly object.
 /// </summary>
 /// <param name="runFilter">The test run filter object.</param>
 /// <param name="testHarness">Harness object.</param>
 /// <param name="provider">The unit test metadata provider.</param>
 /// <param name="testAssembly">The test assembly metadata object.</param>
 public AssemblyManager(TestRunFilter runFilter, UnitTestHarness testHarness, IUnitTestProvider provider, IAssembly testAssembly)
     : base(testHarness, provider)
 {
     _filter        = runFilter;
     _assembly      = testAssembly;
     _testClasses   = new CompositeWorkItem();
     ClassInstances = new TestClassInstanceDictionary();
 }
コード例 #9
0
 /// <summary>
 /// Creates a new unit test assembly wrapper.
 /// </summary>
 /// <param name="provider">Unit test metadata provider.</param>
 /// <param name="unitTestHarness">A reference to the unit test harness.</param>
 /// <param name="assembly">Assembly reflection object.</param>
 public UnitTestFrameworkAssembly(IUnitTestProvider provider, UnitTestHarness unitTestHarness, Assembly assembly)
 {
   _provider = provider;
   _harness = unitTestHarness;
   _assembly = assembly;
   _init = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyInitialize);
   _cleanup = new LazyAssemblyMethodInfo(_assembly, ProviderAttributes.AssemblyCleanup);
 }
コード例 #10
0
 /// <summary>
 /// A container type that handles an entire test class throughout the
 /// test run.
 /// </summary>
 /// <param name="filter">Test run filter object.</param>
 /// <param name="testHarness">The unit test harness.</param>
 /// <param name="testClass">The test class metadata interface.</param>
 /// <param name="instance">The object instance.</param>
 /// <param name="provider">The unit test provider.</param>
 public TestClassManager(TestRunFilter filter, UnitTestHarness testHarness, ITestClass testClass, object instance, IUnitTestProvider provider)
     : base(testHarness, provider)
 {
     _filter             = filter;
     _testClass          = testClass;
     _testExecutionQueue = new CompositeWorkItem();
     _instance           = instance;
 }
コード例 #11
0
    /// <summary>
    /// Initializes a new intance of the UnitTestHarnessEvents helper.
    /// </summary>
    /// <param name="harness">The harness reference.</param>
    public UnitTestHarnessEvents(UnitTestHarness harness)
    {
      if (harness == null)
      {
        throw new ArgumentNullException("harness");
      }

      _harness = harness;
    }
コード例 #12
0
ファイル: DataManager.cs プロジェクト: fstn/WindowsPhoneApps
        /// <summary>
        /// Initializes a new instance of the DataManager type.
        /// </summary>
        /// <param name="harness">The unit test harness instance.</param>
        private DataManager(UnitTestHarness harness)
        {
            _d = new TestRunData(harness);
            _h = harness;

            _assemblyData = new Dictionary<IAssembly, TestAssemblyData>(2);
            _classData = new Dictionary<ITestClass, TestClassData>(50);
            _methodData = new Dictionary<ITestMethod, TestMethodData>(300);
        }
コード例 #13
0
        /// <summary>
        /// Initializes a new intance of the UnitTestHarnessEvents helper.
        /// </summary>
        /// <param name="harness">The harness reference.</param>
        public UnitTestHarnessEvents(UnitTestHarness harness)
        {
            if (harness == null)
            {
                throw new ArgumentNullException("harness");
            }

            _harness = harness;
        }
コード例 #14
0
 /// <summary>
 /// Initializes a new unit test work item container.
 /// </summary>
 /// <param name="testHarness">The unit test harness.</param>
 /// <param name="unitTestProvider">The unit test metadata provider.</param>
 protected UnitTestCompositeWorkItem(UnitTestHarness testHarness, IUnitTestProvider unitTestProvider)
   : base()
 {
   _provider = unitTestProvider;
   TestHarness = testHarness;
   if (TestHarness == null)
   {
     throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestCompositeWorkItem_ctor_NoTestHarness);
   }
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new unit test work item container.
 /// </summary>
 /// <param name="testHarness">The unit test harness.</param>
 /// <param name="unitTestProvider">The unit test metadata provider.</param>
 protected UnitTestCompositeWorkItem(UnitTestHarness testHarness, IUnitTestProvider unitTestProvider)
     : base()
 {
     _provider   = unitTestProvider;
     TestHarness = testHarness;
     if (TestHarness == null)
     {
         throw new InvalidOperationException(Properties.UnitTestMessage.UnitTestCompositeWorkItem_ctor_NoTestHarness);
     }
 }
コード例 #16
0
        /// <summary>
        /// Records a harness state for the unit test harness.
        /// </summary>
        /// <param name="harness">The unit test harness.</param>
        /// <param name="name">The harness name.</param>
        /// <param name="stage">The test stage.</param>
        public void UnitTestHarnessStage(UnitTestHarness harness, string name, TestStage stage)
        {
            LogMessage m = Create(LogMessageType.TestExecution, name);

            MarkUnitTestMessage(m);
            DecorateNameProperty(m, name);
            DecorateTestGranularity(m, TestGranularity.Harness);
            m[UnitTestLogDecorator.UnitTestHarness] = harness;
            DecorateTestStage(m, stage);
            Enqueue(m);
        }
コード例 #17
0
ファイル: TestRunData.cs プロジェクト: fstn/WindowsPhoneApps
 /// <summary>
 /// Initializes a new instance of the test run results.
 /// </summary>
 /// <param name="unitTestHarness">The unit test harness.</param>
 public TestRunData(UnitTestHarness unitTestHarness)
 {
   Passed = true;
   _assemblies = new ObservableCollection<TestAssemblyData>();
   _harness = unitTestHarness;
   _harness.TestAssemblyStarting += (x, xe) => IsRunning = true;
   _harness.TestAssemblyCompleted += (x, xe) =>
       {
         IsRunning = false;
         NotifyPropertyChanged("PassedAndComplete");
       };
   _harness.IsDispatcherRunningChanged += (x, xe) => NotifyPropertyChanged("IsDispatcherRunning");
 }
コード例 #18
0
        /// <summary>
        /// Initialize a new writer class.
        /// </summary>
        /// <param name="harness">The test harness instance.</param>
        /// <param name="messageFactory">
        /// The factory to use when creating new messages.
        /// </param>
        public LogMessageWriter(UnitTestHarness harness, LogMessageFactory messageFactory)
        {
            if (harness == null)
            {
                throw new ArgumentNullException("harness");
            }
            else if (messageFactory == null)
            {
                throw new ArgumentNullException("messageFactory");
            }

            _testHarness = harness;
            _factory     = messageFactory;
        }
コード例 #19
0
    /// <summary>
    /// Initialize a new writer class.
    /// </summary>
    /// <param name="harness">The test harness instance.</param>
    /// <param name="messageFactory">
    /// The factory to use when creating new messages.
    /// </param>
    public LogMessageWriter(UnitTestHarness harness, LogMessageFactory messageFactory)
    {
      if (harness == null)
      {
        throw new ArgumentNullException("harness");
      }
      else if (messageFactory == null)
      {
        throw new ArgumentNullException("messageFactory");
      }

      _testHarness = harness;
      _factory = messageFactory;
    }
コード例 #20
0
 public void WriteLogFile(UnitTestHarness harness)
 {
   _writer.Finished = DateTime.Now;
   harness.WriteLogFile(TestResultsFileName, _writer.GetXmlAsString());
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new test run filter using an existing settings file.
 /// </summary>
 /// <param name="settings">A unit test settings instance.</param>
 /// <param name="harness">The unit test harness.</param>
 public TestRunFilter(UnitTestSettings settings, UnitTestHarness harness)
 {
     TestRunName     = DefaultTestRunName;
     _settings       = settings;
     UnitTestHarness = harness;
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the TestAssemblyStartingEventArgs
 /// type.
 /// </summary>
 /// <param name="assembly">The assembly metadata.</param>
 /// <param name="harness">The unit test harness instance.</param>
 public TestAssemblyStartingEventArgs(IAssembly assembly, UnitTestHarness harness)
     : base(harness)
 {
     Assembly = assembly;
 }
コード例 #23
0
 /// <summary>
 /// Initializes a new unit test logic factory.
 /// </summary>
 /// <param name="harness">The unit test harness reference.</param>
 public UnitTestLogicFactory(UnitTestHarness harness)
 {
   _harness = harness;
 }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of the TestClassCompletedEventArgs
 /// class.
 /// </summary>
 /// <param name="testClass">Test class metadata.</param>
 /// <param name="harness">The harness instance.</param>
 public TestClassCompletedEventArgs(ITestClass testClass, UnitTestHarness harness)
     : base(harness)
 {
     TestClass = testClass;
 }
コード例 #25
0
 /// <summary>
 /// Initializes the unit test log message writer helper.
 /// </summary>
 /// <param name="harness">The test harness reference.</param>
 public UnitTestLogMessageWriter(UnitTestHarness harness)
   : base(harness)
 {
 }
コード例 #26
0
 /// <summary>
 /// Initializes the MobileTestPage object.
 /// </summary>
 /// <param name="harness">The test harness instance.</param>
 public TestPage(UnitTestHarness harness)
   : this()
 {
   harness.TestPage = this;
   _harness = harness;
 }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the TestAssemblyCompletedEventArgs
 /// type.
 /// </summary>
 /// <param name="assembly">The assembly metadata.</param>
 /// <param name="harness">The test harness instance.</param>
 public TestAssemblyCompletedEventArgs(IAssembly assembly, UnitTestHarness harness)
     : base(harness)
 {
     Assembly = assembly;
 }
コード例 #28
0
 /// <summary>
 /// Initializes a new instance of the TestClassStartingEventArgs type.
 /// </summary>
 /// <param name="testClass">The test class metadata.</param>
 /// <param name="harness">The unit test harness reference.</param>
 public TestClassStartingEventArgs(ITestClass testClass, UnitTestHarness harness)
     : base(harness)
 {
     TestClass = testClass;
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new unit test logic factory.
 /// </summary>
 /// <param name="harness">The unit test harness reference.</param>
 public UnitTestLogicFactory(UnitTestHarness harness)
 {
     _harness = harness;
 }
コード例 #30
0
 /// <summary>
 /// Initializes a new test run filter with the tag expression.
 /// </summary>
 /// <param name="settings">Unit test settings.</param>
 /// <param name="harness">Unit test harness.</param>
 /// <param name="tagExpression">The tag expression to use.</param>
 public TagTestRunFilter(UnitTestSettings settings, UnitTestHarness harness, string tagExpression)
     : base(settings, harness)
 {
     SetTagExpression(tagExpression);
 }
コード例 #31
0
 /// <summary>
 /// Initializes the unit test log message writer helper.
 /// </summary>
 /// <param name="harness">The test harness reference.</param>
 public UnitTestLogMessageWriter(UnitTestHarness harness)
     : base(harness)
 {
 }
コード例 #32
0
 /// <summary>
 /// Initializes a new instance of the TestMethodStartingEventArgs type.
 /// </summary>
 /// <param name="testMethod">The test method metadata.</param>
 /// <param name="testClass">The test class metadata.</param>
 /// <param name="harness">The test harness instance.</param>
 public TestMethodStartingEventArgs(ITestMethod testMethod, ITestClass testClass, UnitTestHarness harness)
     : base(harness)
 {
     TestMethod = testMethod;
     TestClass  = testClass;
 }
コード例 #33
0
 /// <summary>
 /// Initializes a new instance of the TestClassCompletedEventArgs
 /// class.
 /// </summary>
 /// <param name="testClass">Test class metadata.</param>
 /// <param name="harness">The harness instance.</param>
 public TestClassCompletedEventArgs(ITestClass testClass, UnitTestHarness harness)
   : base(harness)
 {
   TestClass = testClass;
 }
コード例 #34
0
 /// <summary>
 /// Initializes a new instance of the UnitTestHarnessEventArgs class.
 /// </summary>
 /// <param name="harness">The test harness.</param>
 public UnitTestHarnessEventArgs(UnitTestHarness harness)
     : base()
 {
     UnitTestHarness = harness;
 }
コード例 #35
0
        /// <summary>
        /// Initializes the test harness.
        /// </summary>
        /// <param name="settings">The test harness settings.</param>
        public void Initialize(UnitTestSettings settings)
        {
            UnitTestHarness uth = settings.TestHarness as UnitTestHarness;

            if (uth != null)
            {
                // Attach to store the log file
                uth.Publishing += (o, e) => WriteLogFile(uth);

                // Look for a unique test run ID
                if (uth.TestService != null)
                {
                    string runId = uth.TestService.UniqueTestRunIdentifier;
                    if (!string.IsNullOrEmpty(runId))
                    {
                        TestRunId = runId;
                    }
                }
            }

            string filename;

            if (settings.Parameters.TryGetValue("log", out filename))
            {
                TestResultsFileName = filename;
            }

            // Read pre-defined optional settings and environment variables
            List <string> prefix = new List <string>();
            string        initialPrefix;

            if (settings.Parameters.TryGetValue("testRunNamePrefix", out initialPrefix))
            {
                prefix.Add(initialPrefix);
            }

            string userName;

            if (settings.Parameters.TryGetValue("userName", out userName))
            {
                prefix.Add(userName);
                UserName = userName;
            }

            string computerName;

            if (settings.Parameters.TryGetValue("computerName", out computerName))
            {
                prefix.Add(computerName);
                ComputerName = computerName;
            }

            for (int i = 0; i < prefix.Count; ++i)
            {
                if (TestRunNamePrefix.Length > 0)
                {
                    TestRunNamePrefix += "_";
                }
                TestRunNamePrefix += prefix[i];
            }
        }
コード例 #36
0
 /// <summary>
 /// Initialize a new writer class, using the default LogMessageFactory
 /// to create new messages.
 /// </summary>
 /// <param name="harness">The test harness instance.</param>
 public LogMessageWriter(UnitTestHarness harness)
     : this(harness, new LogMessageFactory())
 {
 }
コード例 #37
0
 /// <summary>
 /// Initializes a new instance of the TestMethodCompletedEventArgs
 /// type.
 /// </summary>
 /// <param name="result">The result instance.</param>
 /// <param name="harness">The unit test harness.</param>
 public TestMethodCompletedEventArgs(ScenarioResult result, UnitTestHarness harness)
     : base(harness)
 {
     Result = result;
 }
コード例 #38
0
 /// <summary>
 /// Initializes a new test run filter with the tag expression.
 /// </summary>
 /// <param name="settings">Unit test settings.</param>
 /// <param name="harness">Unit test harness.</param>
 /// <param name="tagExpression">The tag expression to use.</param>
 public TagTestRunFilter(UnitTestSettings settings, UnitTestHarness harness, string tagExpression)
   : base(settings, harness)
 {
   SetTagExpression(tagExpression);
 }
コード例 #39
0
 /// <summary>
 /// Initializes a new instance of the TestAssemblyCompletedEventArgs
 /// type.
 /// </summary>
 /// <param name="assembly">The assembly metadata.</param>
 /// <param name="harness">The test harness instance.</param>
 public TestAssemblyCompletedEventArgs(IAssembly assembly, UnitTestHarness harness)
   : base(harness)
 {
   Assembly = assembly;
 }
コード例 #40
0
 /// <summary>
 /// Initializes a new instance of the TestMethodCompletedEventArgs
 /// type.
 /// </summary>
 /// <param name="result">The result instance.</param>
 /// <param name="harness">The unit test harness.</param>
 public TestMethodCompletedEventArgs(ScenarioResult result, UnitTestHarness harness)
   : base(harness)
 {
   Result = result;
 }
コード例 #41
0
 /// <summary>
 /// Initializes a new instance of the UnitTestHarnessEventArgs class.
 /// </summary>
 /// <param name="harness">The test harness.</param>
 public UnitTestHarnessEventArgs(UnitTestHarness harness)
   : base()
 {
   UnitTestHarness = harness;
 }
コード例 #42
0
 /// <summary>
 /// Initializes a new instance of the TestClassStartingEventArgs type.
 /// </summary>
 /// <param name="testClass">The test class metadata.</param>
 /// <param name="harness">The unit test harness reference.</param>
 public TestClassStartingEventArgs(ITestClass testClass, UnitTestHarness harness)
   : base(harness)
 {
   TestClass = testClass;
 }
コード例 #43
0
 /// <summary>
 /// Initializes a new test run filter using an existing settings file.
 /// </summary>
 /// <param name="settings">A unit test settings instance.</param>
 /// <param name="harness">The unit test harness.</param>
 public TestRunFilter(UnitTestSettings settings, UnitTestHarness harness)
 {
   TestRunName = DefaultTestRunName;
   _settings = settings;
   UnitTestHarness = harness;
 }
コード例 #44
0
ファイル: DataManager.cs プロジェクト: fstn/WindowsPhoneApps
 /// <summary>
 /// Initializes a new instance of the DataManager.
 /// </summary>
 /// <param name="harness">The unit test harness instance.</param>
 /// <returns>Returns a new instance of a DataManager class.</returns>
 public static DataManager Create(UnitTestHarness harness)
 {
     return new DataManager(harness);
 }
コード例 #45
0
 /// <summary>
 /// Initializes a new instance of the TestMethodStartingEventArgs type.
 /// </summary>
 /// <param name="testMethod">The test method metadata.</param>
 /// <param name="testClass">The test class metadata.</param>
 /// <param name="harness">The test harness instance.</param>
 public TestMethodStartingEventArgs(ITestMethod testMethod, ITestClass testClass, UnitTestHarness harness)
   : base(harness)
 {
   TestMethod = testMethod;
   TestClass = testClass;
 }
コード例 #46
0
 /// <summary>
 /// Initialize a new writer class, using the default LogMessageFactory
 /// to create new messages.
 /// </summary>
 /// <param name="harness">The test harness instance.</param>
 public LogMessageWriter(UnitTestHarness harness)
   : this(harness, new LogMessageFactory())
 {
 }
コード例 #47
0
 /// <summary>
 /// Records a harness state for the unit test harness.
 /// </summary>
 /// <param name="harness">The unit test harness.</param>
 /// <param name="name">The harness name.</param>
 /// <param name="stage">The test stage.</param>
 public void UnitTestHarnessStage(UnitTestHarness harness, string name, TestStage stage)
 {
   LogMessage m = Create(LogMessageType.TestExecution, name);
   MarkUnitTestMessage(m);
   DecorateNameProperty(m, name);
   DecorateTestGranularity(m, TestGranularity.Harness);
   m[UnitTestLogDecorator.UnitTestHarness] = harness;
   DecorateTestStage(m, stage);
   Enqueue(m);
 }
コード例 #48
0
 public void WriteLogFile(UnitTestHarness harness)
 {
     _writer.Finished = DateTime.Now;
     harness.WriteLogFile(TestResultsFileName, _writer.GetXmlAsString());
 }
コード例 #49
0
 /// <summary>
 /// Initializes a new instance of the TestAssemblyStartingEventArgs
 /// type.
 /// </summary>
 /// <param name="assembly">The assembly metadata.</param>
 /// <param name="harness">The unit test harness instance.</param>
 public TestAssemblyStartingEventArgs(IAssembly assembly, UnitTestHarness harness)
   : base(harness)
 {
   Assembly = assembly;
 }