public void DiscoveryResultCacheConstructorShouldInitializeDiscoveredTestsList()
        {
            var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });

            Assert.IsNotNull(cache.Tests);
            Assert.AreEqual(0, cache.Tests.Count);
        }
Exemplo n.º 2
0
        public void TestInit()
        {
            this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>();
            this.discoveryResultCache        = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });
            this.discovererEnumerator        = new DiscovererEnumerator(this.discoveryResultCache, this.mockTestPlatformEventSource.Object);

            TestDiscoveryExtensionManager.Destroy();
        }
        public void TestInit()
        {
            this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>();
            this.discoveryResultCache        = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });
            this.mockRequestData             = new Mock <IRequestData>();
            this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(new NoOpMetricsCollection());
            this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object);

            TestDiscoveryExtensionManager.Destroy();
        }
        public void AddTestShouldIncreaseDiscoveredTestsCount()
        {
            var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });

            var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A");

            cache.AddTest(testCase);

            Assert.AreEqual(1, cache.TotalDiscoveredTests);
        }
        public void AddTestShouldAddATestCaseToTheList()
        {
            var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });

            var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A");

            cache.AddTest(testCase);

            Assert.AreEqual(1, cache.Tests.Count);
            Assert.AreEqual(testCase, cache.Tests[0]);
        }
        public void AddTestShouldReportTestCasesIfCacheTimeoutIsMet()
        {
            ICollection <TestCase> reportedTestCases = null;
            var cache = new DiscoveryResultCache(100, TimeSpan.FromMilliseconds(10), (tests) => { reportedTestCases = tests; });

            var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A");

            Task.Delay(20).Wait();
            cache.AddTest(testCase);

            Assert.IsNotNull(reportedTestCases);
            Assert.AreEqual(1, reportedTestCases.Count);
            Assert.AreEqual(testCase, reportedTestCases.ToArray()[0]);
        }
        public void SendTestCaseShouldSendTestCasesToCache()
        {
            var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });
            var sink  = new TestCaseDiscoverySink(cache);

            var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A");

            sink.SendTestCase(testCase);

            // Assert that the cache has the test case.
            Assert.IsNotNull(cache.Tests);
            Assert.AreEqual(1, cache.Tests.Count);
            Assert.AreEqual(testCase, cache.Tests[0]);
        }
Exemplo n.º 8
0
 public DiscovererEnumeratorTests()
 {
     this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>();
     this.discoveryResultCache        = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });
     this.mockRequestData             = new Mock <IRequestData>();
     this.mockMetricsCollection       = new Mock <IMetricsCollection>();
     this.mockAssemblyProperties      = new Mock <IAssemblyProperties>();
     this.mockRequestData.Setup(rd => rd.MetricsCollection).Returns(this.mockMetricsCollection.Object);
     this.discovererEnumerator = new DiscovererEnumerator(this.mockRequestData.Object, this.discoveryResultCache, this.mockTestPlatformEventSource.Object, this.mockAssemblyProperties.Object, this.cancellationTokenSource.Token);
     this.runSettingsMock      = new Mock <IRunSettings>();
     this.messageLoggerMock    = new Mock <IMessageLogger>();
     TestPluginCacheTests.SetupMockExtensions(new string[] { typeof(DiscovererEnumeratorTests).GetTypeInfo().Assembly.Location },
                                              () => { });
     TestDiscoveryExtensionManager.Destroy();
 }
        public void AddTestShouldResetTestListOnceCacheSizeIsMet()
        {
            var cache = new DiscoveryResultCache(2, TimeSpan.FromHours(1), (tests) => { });

            var testCase1 = new TestCase("A.C.M", new Uri("executor://unittest"), "A");
            var testCase2 = new TestCase("A.C.M2", new Uri("executor://unittest"), "A");

            cache.AddTest(testCase1);
            cache.AddTest(testCase2);

            Assert.IsNotNull(cache.Tests);
            Assert.AreEqual(0, cache.Tests.Count);

            // Validate that total tests is no reset though.
            Assert.AreEqual(2, cache.TotalDiscoveredTests);
        }
        public void AddTestShouldResetTestListIfCacheTimeoutIsMet()
        {
            ICollection <TestCase> reportedTestCases = null;
            var cache = new DiscoveryResultCache(100, TimeSpan.FromMilliseconds(10), (tests) => { reportedTestCases = tests; });

            var testCase = new TestCase("A.C.M", new Uri("executor://unittest"), "A");

            Task.Delay(20).Wait();
            cache.AddTest(testCase);

            Assert.IsNotNull(cache.Tests);
            Assert.AreEqual(0, cache.Tests.Count);

            // Validate that total tests is no reset though.
            Assert.AreEqual(1, cache.TotalDiscoveredTests);
        }
        public void AddTestShouldReportTestCasesIfMaxCacheSizeIsMet()
        {
            ICollection <TestCase> reportedTestCases = null;
            var cache = new DiscoveryResultCache(2, TimeSpan.FromHours(1), (tests) => { reportedTestCases = tests; });

            var testCase1 = new TestCase("A.C.M", new Uri("executor://unittest"), "A");
            var testCase2 = new TestCase("A.C.M2", new Uri("executor://unittest"), "A");

            cache.AddTest(testCase1);
            cache.AddTest(testCase2);

            Assert.IsNotNull(reportedTestCases);
            Assert.AreEqual(2, reportedTestCases.Count);
            CollectionAssert.AreEqual(new List <TestCase> {
                testCase1, testCase2
            }, reportedTestCases.ToList());
        }
        public void DiscoveryResultCacheConstructorShouldInitializeTotalDiscoveredTests()
        {
            var cache = new DiscoveryResultCache(1000, TimeSpan.FromHours(1), (tests) => { });

            Assert.AreEqual(0, cache.TotalDiscoveredTests);
        }