Beispiel #1
0
        public void ShouldUseRetryLogic()
        {
            var acctRepo     = new AccountRepo();
            var acctXferRepo = new AccountTransactionRepo();
            var accounts     = acctRepo.GetAll();
            var xferCount    = acctXferRepo.GetAll().Count;
            var xfer         = new AccountTransaction {
                Account = accounts[1], Amount = -100
            };
            var ex = Assert.Throws <RetryLimitExceededException>(() => acctXferRepo.Add(xfer));

            acctXferRepo.GetAll().Count.ShouldEqual(xferCount);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }