public void DeleteTransactionDeletesTransaction()
        {
            int accountIdForTest = 1;

            //Arrange:
            // Instantiate TransactionsController so its methods can be called
            // Create a new transaction to be deleted, and get its transaction ID
            var transactionController = new TransactionsController();

            var transaction = new TransactionModel
            {
                AccountId = accountIdForTest,
                Amount = 3451.87M,
                TransactionDate = DateTime.Now
            };
            IHttpActionResult result =
                    transactionController.PostTransaction(transaction);
            CreatedAtRouteNegotiatedContentResult<TransactionModel> contentResult =
                (CreatedAtRouteNegotiatedContentResult<TransactionModel>)result;

            int transactionIdToDelete = contentResult.Content.TransactionId;

            //Act: Call DeleteTransaction
            result = transactionController.DeleteTransaction(transactionIdToDelete);

            //Assert:
            // Verify that HTTP result is OK
            // Verify that reading deleted transaction returns result not found
            Assert.IsInstanceOfType(result,
                typeof(OkNegotiatedContentResult<Transaction>));

            result = transactionController.GetTransaction(transactionIdToDelete);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
        [TestMethod]  //{4}
        public void PutTransactionUpdateTransaction()
        {
            IHttpActionResult result;
            CreatedAtRouteNegotiatedContentResult<TransactionModel> contentResult;
            OkNegotiatedContentResult<TransactionModel> transactionResult;


            //Arrange
            using (var transactionsController = new TransactionsController())
            {

                var tsModel = new TransactionModel
                {
                    Amount = 123,                
                };

                result = transactionsController.PostTransaction(tsModel);

                //Cast result as Content Result so that I can gather information from ContentResult
                contentResult = (CreatedAtRouteNegotiatedContentResult<TransactionModel>)result;
            }

            using (var secondTransactionsController = new TransactionsController())
            {

                //Result contains the customer I had JUST createad
                result = secondTransactionsController.GetTransaction(1);

                Assert.IsNotInstanceOfType(result, typeof(NotFoundResult));
                Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<TransactionModel>));
                
                //Get transactionModel from 'result'
                transactionResult = (OkNegotiatedContentResult<TransactionModel>)result;
           
             }

            using (var thirdTransactionsController = new TransactionsController())
            {
                var modifiedContent = transactionResult.Content;

                modifiedContent.Amount += 5;

                //Act
                result = thirdTransactionsController.PutTransaction(transactionResult.Content.TransactionId, modifiedContent);
                //Assert
                Assert.IsInstanceOfType(result, typeof(StatusCodeResult));

            }
        }
        public void PostTransactionCreatesTransaction()
        {
            int accountIdForTest = 1;

            //Arrange: Instantiate TransactionsController so its methods can be called
            var transactionController = new TransactionsController();

            //Act:
            // Create a TransactionModel object populated with test data,
            //  and call PostTransaction
            var newTransaction = new TransactionModel
            {
                AccountId = accountIdForTest,
                Amount = -555M,
                TransactionDate = DateTime.Now

            };
            IHttpActionResult result = transactionController.PostTransaction(newTransaction);

            //Assert:
            // Verify that the HTTP result is CreatedAtRouteNegotiatedContentResult
            // Verify that the HTTP result body contains a nonzero transaction ID
            Assert.IsInstanceOfType
                (result, typeof(CreatedAtRouteNegotiatedContentResult<TransactionModel>));
            CreatedAtRouteNegotiatedContentResult<TransactionModel> contentResult =
                (CreatedAtRouteNegotiatedContentResult<TransactionModel>)result;
            Assert.IsTrue(contentResult.Content.TransactionId != 0);

            // Delete the test transaction
            result = transactionController.DeleteTransaction(contentResult.Content.TransactionId);
        }
        [TestMethod] //{6}
        public void DeleteTransactionDeleteTransaction()
        {
            //Arrange
            //Create Controller
            var transactionsController = new TransactionsController();
            
            //Create a customer to be deleted
            var dbTransactions = new TransactionModel
            {
                Amount = 21323,
               
            };

            //Add 'new customer' to the DB using a POST
            //Save returned value as RESULT
            IHttpActionResult result = transactionsController.PostTransaction(dbTransactions);

            //Cast result as Content Result so that I can gather information from ContentResult
            CreatedAtRouteNegotiatedContentResult<TransactionModel> contentResult = (CreatedAtRouteNegotiatedContentResult<TransactionModel>)result;


            //Result contains the customer I had JUST created
            result = transactionsController.GetTransaction(1);

            //Get CustomerModel from 'result'
            OkNegotiatedContentResult<TransactionModel> customerResult = (OkNegotiatedContentResult<TransactionModel>)result;
            

            //Act
            //The result of the Delete Request
           IHttpActionResult second = transactionsController.DeleteTransaction(1);

            //Assert

            //If action returns: NotFound()
            Assert.IsNotInstanceOfType(second, typeof(NotFoundResult));

            Assert.IsInstanceOfType(second, typeof(OkNegotiatedContentResult<TransactionModel>));
        }
        [TestMethod] // {5}
        public void PostTransactionCreateTransactions()
        {
            //Arrange
            var transactionsController = new TransactionsController();

            //Act
            var newTransaction = new TransactionModel
            {
                Amount = 12,

            };

            IHttpActionResult result = transactionsController.PostTransaction(newTransaction);

            //Assert

            //If not 'true' Assert False
            Assert.IsInstanceOfType(result, typeof(CreatedAtRouteNegotiatedContentResult<TransactionModel>));

            //Cast
            CreatedAtRouteNegotiatedContentResult<TransactionModel> contentResult = (CreatedAtRouteNegotiatedContentResult<TransactionModel>)result;

            //Check if Customer is posted to the database
            //Check to see if Customer ID is NOT equal to zero.  If Customer Id us equal to zero,
            //then customer was NOT added to Database
            Assert.IsTrue(contentResult.Content.AccountId!= 0);
        }