コード例 #1
0
        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));
        }
コード例 #2
0
        public void RetornarTrueParaArquivosComMesmoTamanho()
        {
            // 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.CompareLenght(leftData, rightData);

            // Assert
            Assert.True(result);
        }