コード例 #1
0
        public async Task GetDiffDataShouldReturnDifferencesNotFoundWhenBlocksAreOfSameSizeAndSameSequence()
        {
            // Arrange
            var leftBlock  = new byte[] { 1, 2, 3, 4, 5 };
            var rightBlock = new byte[] { 1, 2, 3, 4, 5 };

            // Act
            ClientSideDiffResult diffResultValue = await GetDiffAnalysisResponseWithSuccess(leftBlock, rightBlock);

            // Assert
            Assert.AreEqual("DifferencesNotFound", diffResultValue.Status);
        }
コード例 #2
0
        /// <summary>
        /// When the expected result found differences, execute the analysis of received response.
        /// </summary>
        /// <param name="result">Result from API call to be analysed.</param>
        /// <param name="expectedDiffBlocks">Expected differences.</param>
        private static void AssertDifferenceFounds(ClientSideDiffResult result, params ClientSideDiffBlock[] expectedDiffBlocks)
        {
            Assert.AreEqual("DifferencesFound", result.Status);
            Assert.AreEqual(expectedDiffBlocks.Length, result.DiffBlocks.Count);

            for (int i = 0; i < expectedDiffBlocks.Length; i++)
            {
                ClientSideDiffBlock expected        = expectedDiffBlocks[i];
                ClientSideDiffBlock resultDiffBlock = result.DiffBlocks.ElementAt(i);
                Assert.AreEqual(expected.Offset, resultDiffBlock.Offset);
                Assert.AreEqual(expected.Lenght, resultDiffBlock.Lenght);
            }
        }
コード例 #3
0
        public async Task GetDiffDataShouldReturnOneDifferenceFoundWhenDifferencesAreInTheMiddleOfLeftBlock()
        {
            // Arrange
            var leftBlock          = new byte[] { 1, 2, 0, 4, 5 };
            var rightBlock         = new byte[] { 1, 2, 3, 4, 5 };
            var expectedDiffBlocks = new ClientSideDiffBlock {
                Offset = 2, Lenght = 1
            };

            // Act
            ClientSideDiffResult diffResultValue = await GetDiffAnalysisResponseWithSuccess(leftBlock, rightBlock);

            // Assert
            AssertDifferenceFounds(diffResultValue, expectedDiffBlocks);
        }
コード例 #4
0
        public async Task GetDiffDataShouldReturnTwoDifferencesFoundsWhenThereIsOneDifferentBlockInTheLeftAndOneInTheRight()
        {
            // Arrange
            var leftBlock  = new byte[] { 0, 0, 3, 4, 5 };
            var rightBlock = new byte[] { 1, 2, 3, 0, 0 };

            ClientSideDiffBlock[] expectedDiffBlocks =
            {
                new ClientSideDiffBlock {
                    Offset = 0, Lenght = 2
                },
                new ClientSideDiffBlock {
                    Offset = 3, Lenght = 2
                }
            };

            // Act
            ClientSideDiffResult diffResultValue = await GetDiffAnalysisResponseWithSuccess(leftBlock, rightBlock);

            // Assert
            AssertDifferenceFounds(diffResultValue, expectedDiffBlocks);
        }