public void DiffController_AddRightMember_ShouldReturn_HttpBadRequest_InvalidBase64String() { var controller = new DiffController(new BinaryDiffService(new BinaryRepository(), new BinaryComparer())); int testId = 7; var response = controller.AddRightMember(testId, new DiffRequest { Data = "InvalidBase64String" }); var actualResult = response as BadRequestResult; var expectedResult = new BadRequestResult(); Assert.IsNotNull(actualResult); Assert.AreEqual(expectedResult.StatusCode, actualResult.StatusCode); }
public void DiffController_CompareMembers_ShouldReturn_SameSizeIdenticalBinaries() { var controller = new DiffController(new BinaryDiffService(new BinaryRepository(), new BinaryComparer())); int testId = 2; var testMockOriginal = File.ReadAllBytes("TestData\\waes.bmp"); var testMockEnlarged = File.ReadAllBytes("TestData\\waes.bmp"); controller.AddLeftMember(testId, new Models.DiffRequest { Data = Convert.ToBase64String(testMockOriginal) }); controller.AddRightMember(testId, new Models.DiffRequest { Data = Convert.ToBase64String(testMockEnlarged) }); var actualResult = controller.CompareMembers(testId); var expectedResult = new DiffResult { ComparisonResult = "The binaries are identical", DiffOffsets = new List <DiffOffset>() }; Assert.AreEqual(expectedResult.ComparisonResult, actualResult.Value.ComparisonResult); CollectionAssert.AreEqual(expectedResult.DiffOffsets, actualResult.Value.DiffOffsets); }
public void DiffController_CompareMembers_ShouldReturn_SameSizeDifferentBinaries() { var controller = new DiffController(new BinaryDiffService(new BinaryRepository(), new BinaryComparer())); int testId = 3; var testMockOriginal = File.ReadAllBytes("TestData\\waes.bmp"); var testMockEnlarged = File.ReadAllBytes("TestData\\waes-inverted.bmp"); controller.AddLeftMember(testId, new Models.DiffRequest { Data = Convert.ToBase64String(testMockOriginal) }); controller.AddRightMember(testId, new Models.DiffRequest { Data = Convert.ToBase64String(testMockEnlarged) }); var actualResult = controller.CompareMembers(testId); var expectedResult = new DiffResult { ComparisonResult = "The binaries are of equal size", DiffOffsets = new List <DiffOffset>() { new DiffOffset { StartIndex = 74, Length = 1 }, new DiffOffset { StartIndex = 106, Length = 1 }, new DiffOffset { StartIndex = 138, Length = 5712 } } }; Assert.AreEqual(expectedResult.ComparisonResult, actualResult.Value.ComparisonResult); CollectionAssert.AreEquivalent(expectedResult.DiffOffsets.ToSimpleList(), actualResult.Value.DiffOffsets.ToSimpleList()); }