public void ShouldSucceedEntireTransaction() { var acctRepo = new AccountRepo(); var acctXferRepo = new AccountTransactionRepo(); var accounts = acctRepo.GetAll(); var xferCount = acctXferRepo.GetAll().Count; var xfers = new List <AccountTransaction>() { new AccountTransaction { Account = accounts[0], Amount = 100, TransactionDate = DateTime.Now }, new AccountTransaction { Account = accounts[1], Amount = -100, TransactionDate = DateTime.Now }, }; acctXferRepo.AddRange(xfers); acctXferRepo.GetAll().Count.ShouldEqual(xferCount + 2); }
public void ShouldFailEntireTransaction() { var acctRepo = new AccountRepo(); var acctXferRepo = new AccountTransactionRepo(); var accounts = acctRepo.GetAll(); var xferCount = acctXferRepo.GetAll().Count; var xfers = new List <AccountTransaction>() { new AccountTransaction { Account = accounts[0], Amount = 100, TransactionDate = DateTime.Now }, new AccountTransaction { Account = accounts[1], Amount = -100 }, }; Assert.Throws <RetryLimitExceededException>(() => acctXferRepo.AddRange(xfers)); acctXferRepo.GetAll().Count.ShouldEqual(xferCount); }