Ejemplo n.º 1
0
        public async Task <bool> Execute(string pathIn, string pathOut)
        {
            try
            {
                var stringBuilder = new StringBuilder();

                // Processando arquivo de entrada.
                var retrived = await _transformerService.ExecuteProcess(pathIn);

                // Obtendo as estatísticas do arquivo de entrada.
                var fileLine = await _reportService.GetStats(retrived);

                stringBuilder.AppendLine(fileLine.GetDescription(_format));
                stringBuilder.AppendLine(fileLine.ToString(_format));

                var logRequest = new LogRequest
                {
                    Path    = pathOut,
                    Content = stringBuilder
                };

                //Salvando arquivo de saída.
                var logResponse = await _writer.SaveData(logRequest);

                return(logResponse.Result);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public async Task ShouldBeDefinedResult(bool returnValue = true)
        {
            var           pathIn  = "my-drive://localfile";
            var           pathOut = "my-drive://localfile";
            List <string> lines   = new List <string>();

            lines.Add("001ç1234567891234çPedroç50000");
            lines.Add("002ç2345675434544345çJose da SilvaçRural");
            lines.Add("003ç10ç[1-10-100,2-30-2.50,3-40-3.10]çPedro");

            if (returnValue)
            {
                _buildSplitter.Setup(i => i.GetSplitter(lines[0], "ç")).Returns(new SalesmanSplitter {
                    LineToSplit = lines[0], Separator = "ç"
                });
                _buildSplitter.Setup(i => i.GetSplitter(lines[1], "ç")).Returns(new CustomerSplitter {
                    LineToSplit = lines[1], Separator = "ç"
                });
                _buildSplitter.Setup(i => i.GetSplitter(lines[2], "ç")).Returns(new SalesDataSplitter {
                    LineToSplit = lines[2], Separator = "ç"
                });
            }

            else
            {
                _buildSplitter.Setup(i => i.GetSplitter(It.IsAny <string>(), It.IsAny <string>())).Throws(new Exception());
            }

            _retriveDataService.Setup(i => i.GetData(pathIn)).ReturnsAsync(lines);

            var result = await _transformService.ExecuteProcess(pathIn);

            if (returnValue)
            {
                result.Custumers.Should().HaveCount(1);
                result.Salesmans.Should().HaveCount(1);
                result.SalesData.Should().HaveCount(1);
            }
            else
            {
                result.Should().BeNull();
            }
        }