public void BeforeRaisingTestRunCompleteShouldWarnIfNoTestsAreRun() { var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); adapterSourceMap.Add("a", new List <string> { "a", "aa" }); adapterSourceMap.Add("b", new List <string> { "b", "ab" }); var executorUriVsSourceList = new Dictionary <Tuple <Uri, string>, IEnumerable <string> >(); executorUriVsSourceList.Add(new Tuple <Uri, string>(new Uri("e://d/"), "A.dll"), new List <string> { "s1.dll " }); this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, null, this.mockTestRunEventsHandler.Object, executorUriVsSourceList, this.mockRequestData.Object); this.runTestsInstance.CallBeforeRaisingTestRunComplete(false); var messageFormat = "No test is available in {0}. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again."; var message = string.Format(messageFormat, "a aa b ab"); this.mockTestRunEventsHandler.Verify(treh => treh.HandleLogMessage(TestMessageLevel.Warning, message), Times.Once); }
public void SendSessionStartShouldCallSessionStartWithCorrectTestSources() { var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); adapterSourceMap.Add("a", new List <string> { "1.dll", "2.dll" }); var mockTestCaseEventsHandler = new Mock <ITestCaseEventsHandler>(); this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, mockTestCaseEventsHandler.Object, this.mockTestRunEventsHandler.Object, this.mockRequestData.Object); this.runTestsInstance.CallSendSessionStart(); mockTestCaseEventsHandler.Verify(x => x.SendSessionStart(It.Is <IDictionary <String, object> >( y => y.ContainsKey("TestSources") && ((IEnumerable <string>)y["TestSources"]).Contains("1.dll") && ((IEnumerable <string>)y["TestSources"]).Contains("2.dll") ))); }
public void RunTestsShouldRunTestsForTheSourcesSpecified() { var assemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); adapterSourceMap.Add("a", new List <string> { "a", "aa" }); adapterSourceMap.Add(assemblyLocation, new List <string> { assemblyLocation }); this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, null, this.mockTestRunEventsHandler.Object, this.mockRequestData.Object); bool isExecutorCalled = false; RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (s, rc, fh) => { isExecutorCalled = true; }; this.runTestsInstance.RunTests(); Assert.IsTrue(isExecutorCalled); this.mockTestRunEventsHandler.Verify( treh => treh.HandleTestRunComplete(It.IsAny <TestRunCompleteEventArgs>(), It.IsAny <TestRunChangedEventArgs>(), It.IsAny <ICollection <AttachmentSet> >(), It.IsAny <ICollection <string> >()), Times.Once); }
public void GetExecutorUriExtensionMapShouldReturnDefaultExecutorUrisForTheDiscoverersDefined() { var assemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); adapterSourceMap.Add("a", new List <string> { "a", "aa" }); adapterSourceMap.Add(assemblyLocation, new List <string> { assemblyLocation }); this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, null, this.mockTestRunEventsHandler.Object, this.mockRequestData.Object); var executorUris = this.runTestsInstance.CallGetExecutorUriExtensionMap( new Mock <IFrameworkHandle>().Object, new RunContext()); Assert.IsNotNull(executorUris); CollectionAssert.Contains(executorUris.ToArray(), new Tuple <Uri, string>(new Uri("executor://RunTestWithSourcesDiscoverer"), assemblyLocation)); }
public void GetExecutorUriExtensionMapShouldReturnEmptyOnInvalidSources() { var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); adapterSourceMap.Add("a", new List <string> { "a", "aa" }); this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, null, this.mockTestRunEventsHandler.Object); var executorUris = this.runTestsInstance.CallGetExecutorUriExtensionMap(new Mock <IFrameworkHandle>().Object, new RunContext()); Assert.IsNotNull(executorUris); Assert.AreEqual(0, executorUris.Count()); }
public void SendSessionEndShouldCallSessionEnd() { var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); adapterSourceMap.Add("a", new List <string> { "1.dll", "2.dll" }); var mockTestCaseEventsHandler = new Mock <ITestCaseEventsHandler>(); this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, mockTestCaseEventsHandler.Object, this.mockTestRunEventsHandler.Object, this.mockRequestData.Object); this.runTestsInstance.CallSendSessionEnd(); mockTestCaseEventsHandler.Verify(x => x.SendSessionEnd()); }
public void InvokeExecutorShouldInvokeTestExecutorWithTheSources() { var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); adapterSourceMap.Add("a", new List <string> { "a", "aa" }); adapterSourceMap.Add("b", new List <string> { "b", "ab" }); var executorUriVsSourceList = new Dictionary <Tuple <Uri, string>, IEnumerable <string> >(); var executorUriExtensionTuple = new Tuple <Uri, string>(new Uri("e://d/"), "A.dll"); executorUriVsSourceList.Add(executorUriExtensionTuple, new List <string> { "s1.dll " }); this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, null, this.mockTestRunEventsHandler.Object, executorUriVsSourceList, this.mockRequestData.Object); var testExecutor = new RunTestWithSourcesExecutor(); var extension = new LazyExtension <ITestExecutor, ITestExecutorCapabilities>(testExecutor, new TestExecutorMetadata("e://d/")); IEnumerable <string> receivedSources = null; RunTestWithSourcesExecutor.RunTestsWithSourcesCallback = (sources, rc, fh) => { receivedSources = sources; }; this.runTestsInstance.CallInvokeExecutor(extension, executorUriExtensionTuple, null, null); Assert.IsNotNull(receivedSources); CollectionAssert.AreEqual(new List <string> { "s1.dll " }, receivedSources.ToList()); }
private void SetupForNoTestsAvailable(string testCaseFilter, out string sourcesString) { var testAssemblyLocation = typeof(TestCase).GetTypeInfo().Assembly.Location; var adapterAssemblyLocation = typeof(RunTestsWithSourcesTests).GetTypeInfo().Assembly.Location; var adapterSourceMap = new Dictionary <string, IEnumerable <string> >(); var sources = new[] { testAssemblyLocation, "a" }; sourcesString = string.Join(" ", sources); adapterSourceMap.Add(adapterAssemblyLocation, sources); this.testExecutionContext.TestCaseFilter = testCaseFilter; this.runTestsInstance = new TestableRunTestsWithSources( adapterSourceMap, null, testExecutionContext, null, this.mockTestRunEventsHandler.Object, this.mockRequestData.Object); }