public void Update(Transaction transaction)
        {
            if (transaction.TransactionId < 1) {
                throw new ArgumentOutOfRangeException("TransactionId", "Must be greater than 0");
            }

            _transactionRepository.Update(transaction);
        }
        public void Create(Transaction transaction)
        {
            if (transaction.TransactionId != 0) {
                throw new ArgumentOutOfRangeException("TransactionId", "Must be 0");
            }

            // can do validation here if needed

            _transactionRepository.Insert(transaction);
        }
        public void Post_NewTransaction_InsertsTransaction()
        {
            // arrange
            var newTransaction = new Transaction
            {
                CurrencyCode = "GBP",
                TransactionAmount = 54.99M,
                CreatedDate = DateTime.UtcNow
            };

            var subject = new Api.Controllers.TransactionsController(_transactionService);

            // act
            subject.Post(newTransaction);

            // assert
            _transactionRepositoryMock.Verify(x => x.Insert(newTransaction), Times.Once);
        }
        public void Post_MismatchingId_ThrowsException()
        {
            // arrange
            var existingTransaction = new Transaction
            {
                TransactionId = 2,
                CurrencyCode = "GBP",
                TransactionAmount = 54.99M,
                CreatedDate = DateTime.UtcNow
            };

            var subject = new Api.Controllers.TransactionsController(_transactionService);

            // act
            subject.Put(99, existingTransaction);

            // assert
            Assert.IsTrue(false, "exception should be thrown");
        }
        public void Post_ExistingTransaction_ThrowsException()
        {
            // arrange
            var existingTransaction = new Transaction
            {
                TransactionId = 1
            };

            var subject = new Api.Controllers.TransactionsController(_transactionService);

            // act
            subject.Post(existingTransaction);

            // assert
            Assert.IsTrue(false, "exception should be thrown");
        }
        public void Post_ExistingTansaction_UpdatesTransaction()
        {
            // arrange
            var existingTransaction = new Transaction
            {
                TransactionId = 2,
                CurrencyCode = "GBP",
                TransactionAmount = 54.99M,
                CreatedDate = DateTime.UtcNow
            };

            var subject = new Api.Controllers.TransactionsController(_transactionService);

            // act
            subject.Put(existingTransaction.TransactionId, existingTransaction);

            // assert
            _transactionRepositoryMock.Verify(x => x.Update(existingTransaction), Times.Once);
        }