Пример #1
0
        public async Task TestCreateReportAsyncWithEmptyResults()
        {
            string expectedSource = "expectedSource";
            string actualSource   = "actualSource";
            int    batchSize      = 10;

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

            var reportGenerator = new CountingReportGenerator(
                TestDescription,
                Guid.NewGuid().ToString(),
                expectedSource,
                expectedResults.GetAsyncEnumerator(),
                actualSource,
                actualResults.GetAsyncEnumerator(),
                "resultType1",
                new SimpleTestOperationResultComparer(),
                UnmatchedResultsMaxSize,
                false);

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

            Assert.Equal(0UL, report.TotalExpectCount);
            Assert.Equal(0UL, report.TotalMatchCount);
            Assert.Equal(0UL, report.TotalDuplicateActualResultCount);
            Assert.Equal(0, report.UnmatchedResults.Count);
        }
        public void TestConstructorSuccess()
        {
            string expectedSource = "expectedSource";
            string actualSource   = "actualSource";
            int    batchSize      = 10;
            string resultType     = "resultType1";

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

            var reportGenerator = new CountingReportGenerator(
                TestDescription,
                Guid.NewGuid().ToString(),
                expectedSource,
                expectedResults.GetAsyncEnumerator(),
                actualSource,
                actualResults.GetAsyncEnumerator(),
                resultType,
                new SimpleTestOperationResultComparer(),
                UnmatchedResultsMaxSize);

            Assert.Equal(TestDescription, reportGenerator.TestDescription);
            Assert.Equal(actualSource, reportGenerator.ActualSource);
            Assert.Equal(actualResults.GetAsyncEnumerator(), reportGenerator.ActualTestResults);
            Assert.Equal(expectedSource, reportGenerator.ExpectedSource);
            Assert.Equal(expectedResults.GetAsyncEnumerator(), reportGenerator.ExpectedTestResults);
            Assert.Equal(resultType, reportGenerator.ResultType);
            Assert.Equal(typeof(SimpleTestOperationResultComparer), reportGenerator.TestResultComparer.GetType());
        }
        public async Task TestCreateReportAsync(
            IEnumerable <string> expectedStoreValues,
            IEnumerable <string> actualStoreValues,
            int batchSize,
            ulong expectedTotalExpectedCount,
            ulong expectedTotalMatchCount,
            ulong expectedTotalDuplicateExpectedResultCount,
            ulong expectedTotalDuplicateActualResultCount,
            int expectedMissingResultsCount)
        {
            string expectedSource = "expectedSource";
            string actualSource   = "actualSource";
            string resultType     = TestOperationResultType.Messages.ToString();

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

            var reportGenerator = new CountingReportGenerator(
                TestDescription,
                Guid.NewGuid().ToString(),
                expectedSource,
                expectedResults.GetAsyncEnumerator(),
                actualSource,
                actualResults.GetAsyncEnumerator(),
                resultType,
                new SimpleTestOperationResultComparer(),
                UnmatchedResultsMaxSize,
                false);

            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 = (CountingReport)await reportGenerator.CreateReportAsync();

            Assert.Equal(expectedTotalExpectedCount, report.TotalExpectCount);
            Assert.Equal(expectedTotalMatchCount, report.TotalMatchCount);
            Assert.Equal(expectedTotalDuplicateExpectedResultCount, report.TotalDuplicateExpectedResultCount);
            Assert.Equal(expectedTotalDuplicateActualResultCount, report.TotalDuplicateActualResultCount);
            Assert.Equal(expectedMissingResultsCount, report.UnmatchedResults.Count);
        }
Пример #4
0
        public async Task TestCreateReportAsync(
            IEnumerable <string> expectedStoreValues,
            IEnumerable <string> actualStoreValues,
            int batchSize,
            ulong expectedTotalExpectedCount,
            ulong expectedTotalMatchCount,
            ulong expectedTotalDuplicateExpectedResultCount,
            ulong expectedTotalDuplicateActualResultCount,
            ulong expectedTotalMisorderedActualResultCount,
            ulong expectedMissingResultsCount)
        {
            bool brokerEnabled = false;

            // give fake tracking id and batch id to mimic real scenario
            expectedStoreValues = expectedStoreValues.Select(v => "xx;yy;" + v);
            actualStoreValues   = actualStoreValues.Select(v => "xx;yy;" + v);

            string expectedSource = "expectedSource";
            string actualSource   = "actualSource";
            string resultType     = TestOperationResultType.Messages.ToString();

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

            var reportGenerator = new CountingReportGenerator(
                TestDescription,
                TestMode.Connectivity,
                Topology.SingleNode,
                brokerEnabled,
                Guid.NewGuid().ToString(),
                expectedSource,
                expectedResults.GetAsyncEnumerator(),
                actualSource,
                actualResults.GetAsyncEnumerator(),
                resultType,
                new SimpleTestOperationResultComparer(),
                UnmatchedResultsMaxSize,
                false);

            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 = (CountingReport)await reportGenerator.CreateReportAsync();

            Assert.Equal(expectedTotalExpectedCount, report.TotalExpectCount);
            Assert.Equal(expectedTotalMatchCount, report.TotalMatchCount);
            Assert.Equal(expectedMissingResultsCount, report.TotalUnmatchedCount);
            Assert.Equal(expectedTotalDuplicateExpectedResultCount, report.TotalDuplicateExpectedResultCount);
            Assert.Equal(expectedTotalDuplicateActualResultCount, report.TotalDuplicateActualResultCount);
            Assert.Equal(expectedTotalMisorderedActualResultCount, report.TotalMisorderedActualResultCount);

            Assert.Equal((int)expectedMissingResultsCount, report.UnmatchedResults.Count);
            Assert.Equal((int)expectedTotalDuplicateExpectedResultCount, report.DuplicateExpectedResults.Count);
            Assert.Equal((int)expectedTotalDuplicateActualResultCount, report.DuplicateActualResults.Count);
            Assert.Equal((int)expectedTotalMisorderedActualResultCount, report.MisorderedActualResults.Count);
        }