public async Task TestCreateReportAsyncWithEmptyResults()
        {
            string expectedSource = "expectedSource";
            string actualSource   = "actualSource";
            int    batchSize      = 10;

            var mockExpectedStore = new Mock <ISequentialStore <TestOperationResult> >();
            var expectedResults   = new StoreTestResultCollection <TestOperationResult>(mockExpectedStore.Object, batchSize);
            var mockActualStore   = new Mock <ISequentialStore <TestOperationResult> >();
            var actualResults     = new StoreTestResultCollection <TestOperationResult>(mockActualStore.Object, batchSize);

            var reportGenerator = new DeploymentTestReportGenerator(
                Guid.NewGuid().ToString(),
                expectedSource,
                expectedResults,
                actualSource,
                actualResults);

            var report = (DeploymentTestReport)await reportGenerator.CreateReportAsync();

            Assert.Equal(0UL, report.TotalExpectedDeployments);
            Assert.Equal(0UL, report.TotalActualDeployments);
            Assert.Equal(0UL, report.TotalMatchedDeployments);
            Assert.Equal(0, report.UnmatchedResults.Count);
        }
        public void TestConstructorSuccess()
        {
            string expectedSource = "expectedSource";
            string actualSource   = "actualSource";
            int    batchSize      = 10;

            var mockExpectedStore = new Mock <ISequentialStore <TestOperationResult> >();
            var expectedResults   = new StoreTestResultCollection <TestOperationResult>(mockExpectedStore.Object, batchSize);
            var mockActualStore   = new Mock <ISequentialStore <TestOperationResult> >();
            var actualResults     = new StoreTestResultCollection <TestOperationResult>(mockActualStore.Object, batchSize);

            var reportGenerator = new DeploymentTestReportGenerator(
                Guid.NewGuid().ToString(),
                expectedSource,
                expectedResults,
                actualSource,
                actualResults);

            Assert.Equal(actualSource, reportGenerator.ActualSource);
            Assert.Equal(actualResults, reportGenerator.ActualTestResults);
            Assert.Equal(expectedSource, reportGenerator.ExpectedSource);
            Assert.Equal(expectedResults, reportGenerator.ExpectedTestResults);
            Assert.Equal(TestOperationResultType.Deployment.ToString(), reportGenerator.ResultType);
            Assert.Equal(typeof(DeploymentTestResultComparer), reportGenerator.TestResultComparer.GetType());
        }
Exemple #3
0
        public async Task TestCreateReportAsync(
            IEnumerable <string> expectedStoreValues,
            IEnumerable <string> actualStoreValues,
            int batchSize,
            ulong totalExpectedDeployments,
            ulong totalActualDeployments,
            ulong totalMatchedDeployments,
            int expectedMissingResultsCount,
            DeploymentTestResult lastActualDeploymentTestResult)
        {
            string expectedSource = "expectedSource";
            string actualSource   = "actualSource";
            string resultType     = TestOperationResultType.Deployment.ToString();

            var mockExpectedStore = new Mock <ISequentialStore <TestOperationResult> >();
            var expectedResults   = new StoreTestResultCollection <TestOperationResult>(mockExpectedStore.Object, batchSize);
            var mockActualStore   = new Mock <ISequentialStore <TestOperationResult> >();
            var actualResults     = new StoreTestResultCollection <TestOperationResult>(mockActualStore.Object, batchSize);

            string trackingId      = Guid.NewGuid().ToString();
            var    reportGenerator = new DeploymentTestReportGenerator(
                TestDescription,
                trackingId,
                expectedSource,
                expectedResults,
                actualSource,
                actualResults,
                UnmatchedResultsMaxSize);

            var expectedStoreData = GetStoreData(expectedSource, resultType, expectedStoreValues);

            for (int i = 0; i < expectedStoreData.Count; i += batchSize)
            {
                int startingOffset = i;
                mockExpectedStore.Setup(s => s.GetBatch(startingOffset, batchSize)).ReturnsAsync(expectedStoreData.Skip(startingOffset).Take(batchSize));
            }

            var actualStoreData = GetStoreData(actualSource, resultType, actualStoreValues);

            for (int j = 0; j < expectedStoreData.Count; j += batchSize)
            {
                int startingOffset = j;
                mockActualStore.Setup(s => s.GetBatch(startingOffset, batchSize)).ReturnsAsync(actualStoreData.Skip(startingOffset).Take(batchSize));
            }

            var report = (DeploymentTestReport)await reportGenerator.CreateReportAsync();

            Assert.Equal(totalExpectedDeployments, report.TotalExpectedDeployments);
            Assert.Equal(totalActualDeployments, report.TotalActualDeployments);
            Assert.Equal(totalMatchedDeployments, report.TotalMatchedDeployments);
            Assert.Equal(expectedMissingResultsCount, report.UnmatchedResults.Count);

            if (lastActualDeploymentTestResult != null)
            {
                Assert.True(report.LastActualDeploymentTestResult.HasValue);

                var comparer = new DeploymentTestResultComparer();
                Assert.True(comparer.Matches(lastActualDeploymentTestResult.ToTestOperationResult(), report.LastActualDeploymentTestResult.OrDefault()));
            }
        }