public async Task FilesSame_GetDiff_Diff()
        {
            // Arrange
            const int id = 1;
            var       mockDiffService     = new Mock <IDiffService>();
            var       mockRetrieveService = new Mock <IRetrieveService>();
            var       mockUploadService   = new Mock <IUploadService>();

            mockDiffService.Setup(d => d.GetDiffAsync(id))
            .Returns(Task.FromResult(new DiffResultDTO()
            {
                DiffResultType = ComparisonResult.Equals.ToString()
            }));
            mockRetrieveService.Setup(r => r.LeftFileExistsAsync(id))
            .Returns(Task.FromResult(true));
            mockRetrieveService.Setup(r => r.RightFileExistsAsync(id))
            .Returns(Task.FromResult(true));
            var controller = new FileDiffController(mockDiffService.Object, mockRetrieveService.Object, mockUploadService.Object);

            // Act
            var actionResult = await controller.GetDiffAsync(id);

            var contentResult = actionResult as OkNegotiatedContentResult <DiffResultDTO>;

            // Assert
            Assert.IsNotNull(contentResult, "The action result should not be null!");
            Assert.IsNotNull(contentResult.Content, "The content of the action result should not be null!");
            Assert.AreEqual(ComparisonResult.Equals.ToString(), contentResult.Content.DiffResultType, "The diff result should be Equals!");
            Assert.IsNull(contentResult.Content.Diffs, "The list of diffs should not exist in the results!");
        }
        public async Task FilesSameSizeDifferentContent_GetDiff_Diff()
        {
            // Arrange
            const int id = 1;
            var       mockDiffService     = new Mock <IDiffService>();
            var       mockRetrieveService = new Mock <IRetrieveService>();
            var       mockUploadService   = new Mock <IUploadService>();
            var       diffs = new List <DifferenceDTO>()
            {
                new DifferenceDTO()
                {
                    Offset = 0, Length = 1
                },
                new DifferenceDTO()
                {
                    Offset = 2, Length = 2
                }
            };

            mockDiffService.Setup(d => d.GetDiffAsync(id))
            .Returns(Task.FromResult(new DiffResultDTO()
            {
                DiffResultType = ComparisonResult.ContentDoNotMatch.ToString(),
                Diffs          = diffs
            }));
            mockRetrieveService.Setup(r => r.LeftFileExistsAsync(id))
            .Returns(Task.FromResult(true));
            mockRetrieveService.Setup(r => r.RightFileExistsAsync(id))
            .Returns(Task.FromResult(true));
            var controller = new FileDiffController(mockDiffService.Object, mockRetrieveService.Object, mockUploadService.Object);

            // Act
            var actionResult = await controller.GetDiffAsync(id);

            var contentResult = actionResult as OkNegotiatedContentResult <DiffResultDTO>;

            // Assert
            Assert.IsNotNull(contentResult, "The action result should not be null!");
            Assert.IsNotNull(contentResult.Content, "The content of the action result should not be null!");
            Assert.AreEqual(
                ComparisonResult.ContentDoNotMatch.ToString(),
                contentResult.Content.DiffResultType,
                "The diff result should be ContentDoNotMatch!");
            Assert.IsNotNull(contentResult.Content.Diffs, "The list of diffs should exist in the results!");
            CollectionAssert.AreEqual(
                diffs,
                contentResult.Content.Diffs,
                new DifferenceDTOComparer(),
                "The list of diffs is not matching with the expected result!");
        }
        public async Task RightFileNull_GetDiff_NotFound()
        {
            // Arrange
            const int id = 1;
            var       mockDiffService     = new Mock <IDiffService>();
            var       mockRetrieveService = new Mock <IRetrieveService>();
            var       mockUploadService   = new Mock <IUploadService>();

            mockRetrieveService.Setup(r => r.LeftFileExistsAsync(id))
            .Returns(Task.FromResult(true));
            mockRetrieveService.Setup(r => r.RightFileExistsAsync(id))
            .Returns(Task.FromResult(false));
            var controller = new FileDiffController(mockDiffService.Object, mockRetrieveService.Object, mockUploadService.Object);

            // Act
            var result = await controller.GetDiffAsync(id);

            // Assert
            Assert.IsNotNull(result, "The action result should not be null!");
            Assert.IsInstanceOfType(result, typeof(NotFoundResult), "The action result should be 404-NotFound!");
        }