Esempio n. 1
0
 public void Customer_WhenAlways_HaveProperties()
 {
     SalesProcessor.Domain.Customer.Customer test = new SalesProcessor.Domain.Customer.Customer();
     test.CNPJ         = "test";
     test.BusinessArea = "test";
     test.Name         = "test";
 }
        public void AnalyzeFile_WhenWrongLot_ShoulLogLine()
        {
            //Arrange
            string       anyPath  = "anyPath";
            FileInfo     fileInfo = new FileInfo(anyPath + "anyfilename.something");
            MemoryStream ms       = new MemoryStream(Encoding.UTF8.GetBytes("007ç2345675434544345çJose da SilvaçRural"));

            _streamReader.Setup(x => x.GetStreamReader(fileInfo.FullName)).Returns(new System.IO.StreamReader(ms));
            _lotsettings.Object.recordSeparator = "ç";
            var expectedCustomer = new SalesProcessor.Domain.Customer.Customer()
            {
                CNPJ = "2345675434544345"
            };

            //Act
            Assert.ThrowsAsync <System.Exception>(() => _sut.AnalyzeFile(fileInfo));
            _logger.Verify(x => x.Warning(It.IsAny <string>()));
        }
        public void AnalyzeFile_WhenCorrectLot_ShouldCallReportGenerator()
        {
            //Arrange
            string       anyPath  = "anyPath";
            FileInfo     fileInfo = new FileInfo(anyPath + "anyfilename.something");
            MemoryStream ms       = new MemoryStream(Encoding.UTF8.GetBytes("002ç2345675434544345çJose da SilvaçRural"));

            _streamReader.Setup(x => x.GetStreamReader(fileInfo.FullName)).Returns(new System.IO.StreamReader(ms));
            _lotsettings.Object.recordSeparator = "ç";
            var expectedCustomer = new SalesProcessor.Domain.Customer.Customer()
            {
                CNPJ = "2345675434544345"
            };

            //Act
            _sut.AnalyzeFile(fileInfo);

            //Assert
            _reportGeneratorService.Verify(x => x.GenerateReport(It.Is <SalesProcessor.Domain.Lot.Lot>(l => l.customers.Find(x => x.CNPJ == expectedCustomer.CNPJ).CNPJ == expectedCustomer.CNPJ)));
        }