public ActionResult <ResultReport> Diff() { if (!ModelState.IsValid) { return(BadRequest()); } var response = new ResultReport(); var leftFile = $"{Directory.GetCurrentDirectory()}\\inputs\\left"; var rightFile = $"{Directory.GetCurrentDirectory()}\\inputs\\right"; var fileComparer = new DataComparer(); // Verifica se os dados são de diferente tamanho. if (!fileComparer.CompareLenght(leftFile, rightFile)) { response.Report = ReportEnum.DadosDiferentes; } // Comparar cada byte, já que são do mesmo tamanho. response = fileComparer.CompareBytes(leftFile, rightFile); return(Ok(response)); }
public void RetornaReportComOffsetsParaDadosDiferentesComMesmoTamanho() { // Arranje var guid = Guid.NewGuid(); var nameLeft = $"left-test-{guid}"; var nameRight = $"right-test-{guid}"; FileHelper.SaveData("dGlueQ==", nameLeft); FileHelper.SaveData("dGlxeQ==", nameRight); var dc = new DataComparer(); var leftData = $"{Directory.GetCurrentDirectory()}\\inputs\\{nameLeft}"; var rightData = $"{Directory.GetCurrentDirectory()}\\inputs\\{nameRight}"; // Act var result = dc.CompareBytes(leftData, rightData); // Assert Assert.True(result.OffsetDifferences.Any()); }
public void RetornaReportDadosIguaisParaDadosIguais() { // Arranje var guid = Guid.NewGuid(); var nameLeft = $"left-test-{guid}"; var nameRight = $"right-test-{guid}"; FileHelper.SaveData("dGlueQ==", nameLeft); FileHelper.SaveData("dGlueQ==", nameRight); var dc = new DataComparer(); var leftData = $"{Directory.GetCurrentDirectory()}\\inputs\\{nameLeft}"; var rightData = $"{Directory.GetCurrentDirectory()}\\inputs\\{nameRight}"; // Act var result = dc.CompareBytes(leftData, rightData); // Assert Assert.True(result.Report == ReportEnum.DadosIguais); }