public void ShouldNotImportTransactionWhenThereIsTransactionPersistedAndItIsTheSame() { var transactionRepositoryMock = new Mock <ITransactionRepository>(); transactionRepositoryMock.Setup(x => x.GetTransactionsByPeriod(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(new List <Transaction> { new Transaction("CREDIT", DateTime.Now.AddDays(-3).Date, 100, "teste") }); var importerFileServiceMock = new Mock <IFileImporterService>(); var importedFileModel = new ImportedFileModel() { Transactions = new List <TransactionImportedFileModel>() { new TransactionImportedFileModel() { Amount = 100, DatePosted = DateTime.Now.AddDays(-3).Date, Description = "teste", Type = "CREDIT" } } }; importerFileServiceMock.Setup(x => x.Import(It.IsAny <IFormFile>())).Returns(importedFileModel); var sut = new TransactionService(transactionRepositoryMock.Object, importerFileServiceMock.Object); var result = sut.Import(It.IsAny <IFormFile>()); Assert.True(result.Success); Assert.True(result.Error == null); Assert.True(result.TransactionsImportedQuantity == 0); }
public void ShouldNotImportTransactionWhenThereIsAnUnexpectedErrorInFlow() { var filePath = Path.Combine("C:\\Projetos\\nibo_projeto\\ConciliateBankStatement\\src\\ConciliateBankStatement.Core.UnitTests", "teste.ofx"); var transactionRepositoryMock = new Mock <ITransactionRepository>(); transactionRepositoryMock.Setup(x => x.GetTransactionsByPeriod(It.IsAny <DateTime>(), It.IsAny <DateTime>())).Returns(() => throw new Exception()); var importerFileServiceMock = new Mock <IFileImporterService>(); var importedFileModel = new ImportedFileModel() { Transactions = new List <TransactionImportedFileModel>() { new TransactionImportedFileModel() { Amount = 100, DatePosted = DateTime.Now.AddDays(-3).Date, Description = "teste", Type = "CREDIT" } } }; importerFileServiceMock.Setup(x => x.Import(It.IsAny <IFormFile>())).Returns(importedFileModel); var sut = new TransactionService(transactionRepositoryMock.Object, importerFileServiceMock.Object); var result = sut.Import(It.IsAny <IFormFile>()); Assert.True(result.Success == false); Assert.True(result.Error != null); Assert.True(result.TransactionsImportedQuantity == 0); }
public void OpenFileDescription(ImportedFileModel importedFileModel) { _importedFileModel = importedFileModel; _importedFileModel.FileDeleted += OnFileModelDeleted; _fileDescriptionWindow = _fileDescriptionWindowFunc(); _fileDescriptionWindow.DataContext = this; _fileDescriptionWindow.Show(); }
public void ConvertibleFileBase_ShouldChangeImportedFileProcessStateCancel(string fileName, byte[] result, string fileOriginalPath) { //Arrange var fileModel = new ImportedFileModel(fileName, result, fileOriginalPath); var objConvertibleFile = new StepConvertibleFile(fileModel); //Act objConvertibleFile.DeleteFile(); //Assert fileModel.ConvertProcessType.Should().Be(ConvertProcessType.Cancel); }
public IConvertibleFile GetConvertibleFile(ImportedFileModel fileModel, ConvertType type) { var convertible = type switch { ConvertType.Step => (IConvertibleFile) new StepConvertibleFile(fileModel), ConvertType.Stl => new StlConvertibleFile(fileModel), ConvertType.Obj => new ObjConvertibleFile(fileModel), _ => new StepConvertibleFile(fileModel) }; convertible.Convert(); return(convertible); } }
private ImportedFileModel MapTransactionByFile(string line) { var fileImportedModel = new ImportedFileModel { DateStart = GetDateFromTag(line.Split("<DTSTART>")[1].Split("<DTEND>")[0]), DateEnd = GetDateFromTag(line.Split("<DTEND>")[1].Split("<STMTTRN>")[0]) }; for (var i = 1; i < line.Split("<STMTTRN>").Length; i++) { var transactionFile = line.Split("<STMTTRN>")[i]; var properties = transactionFile.Split('<', '>'); var transactionFileImportedModel = new TransactionImportedFileModel(); for (var j = 0; j < properties.Length; j++) { if (string.IsNullOrEmpty(properties[j]) || properties[j][0] == '/') { continue; } switch (properties[j]) { case "TRNTYPE": transactionFileImportedModel.Type = properties[j + 1]; break; case "MEMO": transactionFileImportedModel.Description = properties[j + 1]; break; case "DTPOSTED": transactionFileImportedModel.DatePosted = GetDateFromTag(properties[j + 1].Substring(0, 8)); break; case "TRNAMT": transactionFileImportedModel.Amount = decimal.Parse(properties[j + 1]); break; } j++; } fileImportedModel.Transactions.Add(transactionFileImportedModel); } return(fileImportedModel); }
public StlConvertibleFile(ImportedFileModel fileModel) : base(fileModel) { FileName = fileModel.FileName.Replace(".shapr", ".stl"); }
public ImportedFileViewModel CreateImportedFileModel(ImportedFileModel model) { return(_importedFileViewModel.Invoke().WithModel(model)); }
protected ConvertibleFileBase(ImportedFileModel fileModel) { _fileModel = fileModel; _fileModel.FileDeleted += OnDeleted; }