Inheritance: ITestDiscoverer
コード例 #1
0
        private void CheckForDiscoverySinkCalls(int expectedNrOfTests, string customRegex = null)
        {
            Mock<IDiscoveryContext> mockDiscoveryContext = new Mock<IDiscoveryContext>();
            Mock<ITestCaseDiscoverySink> mockDiscoverySink = new Mock<ITestCaseDiscoverySink>();
            MockOptions.Setup(o => o.TestDiscoveryRegex).Returns(() => customRegex);

            TestDiscoverer discoverer = new TestDiscoverer(TestEnvironment);
            Mock<IMessageLogger> mockVsLogger = new Mock<IMessageLogger>();
            discoverer.DiscoverTests(TestResources.X86StaticallyLinkedTests.Yield(), mockDiscoveryContext.Object, mockVsLogger.Object, mockDiscoverySink.Object);

            mockDiscoverySink.Verify(h => h.SendTestCase(It.IsAny<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>()), Times.Exactly(expectedNrOfTests));
        }
コード例 #2
0
        private void CheckForDiscoverySinkCalls(int expectedNrOfTests, string customRegex = null)
        {
            Mock <IDiscoveryContext>      mockDiscoveryContext = new Mock <IDiscoveryContext>();
            Mock <ITestCaseDiscoverySink> mockDiscoverySink    = new Mock <ITestCaseDiscoverySink>();

            MockOptions.Setup(o => o.TestDiscoveryRegex).Returns(() => customRegex);

            TestDiscoverer        discoverer   = new TestDiscoverer(TestEnvironment);
            Mock <IMessageLogger> MockVsLogger = new Mock <IMessageLogger>();

            discoverer.DiscoverTests(X86StaticallyLinkedTests.Yield(), mockDiscoveryContext.Object, MockVsLogger.Object, mockDiscoverySink.Object);

            mockDiscoverySink.Verify(h => h.SendTestCase(It.IsAny <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>()), Times.Exactly(expectedNrOfTests));
        }
コード例 #3
0
        private void RunExecutableAndCheckLogging(string executable, Action verify)
        {
            var mockDiscoveryContext = new Mock <IDiscoveryContext>();
            var mockDiscoverySink    = new Mock <ITestCaseDiscoverySink>();
            var mockVsLogger         = new Mock <IMessageLogger>();

            MockOptions.Setup(o => o.TestDiscoveryRegex).Returns(() => ".*");

            var discoverer = new TestDiscoverer(TestEnvironment.Logger, TestEnvironment.Options);

            discoverer.DiscoverTests(executable.Yield(), mockDiscoveryContext.Object, mockVsLogger.Object,
                                     mockDiscoverySink.Object);

            verify();
        }
コード例 #4
0
        private void RunExecutableAndCheckLogging(string executable)
        {
            var mockDiscoveryContext = new Mock <IDiscoveryContext>();
            var mockDiscoverySink    = new Mock <ITestCaseDiscoverySink>();
            var mockVsLogger         = new Mock <IMessageLogger>();

            MockOptions.Setup(o => o.TestDiscoveryRegex).Returns(() => ".*");

            var discoverer = new TestDiscoverer(TestEnvironment.Logger, TestEnvironment.Options);

            discoverer.DiscoverTests(executable.Yield(), mockDiscoveryContext.Object, mockVsLogger.Object,
                                     mockDiscoverySink.Object);

            MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("Could not list test cases of executable"))),
                              Times.Once);
        }
コード例 #5
0
        private void CheckForDiscoverySinkCalls(int expectedNrOfTests, string customRegex = null)
        {
            string dir = Utils.GetTempDirectory();

            try
            {
                string targetFile = Path.Combine(dir, "MyTests.exe");
                File.Copy(TestResources.Tests_DebugX86, targetFile);

                Mock <IDiscoveryContext>      mockDiscoveryContext = new Mock <IDiscoveryContext>();
                Mock <ITestCaseDiscoverySink> mockDiscoverySink    = new Mock <ITestCaseDiscoverySink>();
                MockOptions.Setup(o => o.TestDiscoveryRegex).Returns(() => customRegex);

                TestDiscoverer        discoverer   = new TestDiscoverer(TestEnvironment.Logger, TestEnvironment.Options);
                Mock <IMessageLogger> mockVsLogger = new Mock <IMessageLogger>();
                discoverer.DiscoverTests(targetFile.Yield(), mockDiscoveryContext.Object, mockVsLogger.Object, mockDiscoverySink.Object);

                mockDiscoverySink.Verify(h => h.SendTestCase(It.IsAny <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>()), Times.Exactly(expectedNrOfTests));
            }
            finally
            {
                Utils.DeleteDirectory(dir);
            }
        }