public void ImportFilesTest_ImportFileWithMultipleRecords() { // Given var mockLogFile = Substitute.For <ILogFile>(); var transactionDataService = Substitute.For <ITransactionDataService>(); transactionDataService.Add(Arg.Any <Transaction>()).Returns(true); var unitUnderTest = CreateUnitUnderTest(transactionDataService, mockLogFile); // When unitUnderTest.ImportFiles(new List <string>() { mFileWithMultipleRecords.Name }); // Then mockLogFile.DidNotReceive().Error(Arg.Any <string>()); // Test that the correct transaction has been added. transactionDataService.Received(3).Add(Arg.Any <Transaction>()); transactionDataService.Received(1).Add(Arg.Is <Transaction>(t => t.IsEqual(mFileWithMultipleRecords.GetTransactionByIndex(0)))); transactionDataService.Received(1).Add(Arg.Is <Transaction>(t => t.IsEqual(mFileWithMultipleRecords.GetTransactionByIndex(1)))); transactionDataService.Received(1).Add(Arg.Is <Transaction>(t => t.IsEqual(mFileWithMultipleRecords.GetTransactionByIndex(2)))); }
public void ImportFilesTest_ImportFileWithOneRecord() { // Creation and initialization. var mockLogFile = Substitute.For <ILogFile>(); var transactionDataService = Substitute.For <ITransactionDataService>(); transactionDataService.Add(Arg.Any <Transaction>()).Returns(true); var unitUnderTest = CreateUnitUnderTest(transactionDataService, mockLogFile); // Start test unitUnderTest.ImportFiles(new List <string>() { mFileWithOneRecord.Name }); // Check test results mockLogFile.DidNotReceive().Error(Arg.Any <string>()); // Test that the correct transaction has been added. transactionDataService.Received(1).Add(Arg.Is <Transaction>(t => t.IsEqual(mFileWithOneRecord.GetTransactionByIndex(0)))); }