public void DeleteTransaction_ShouldDeleteTransactionWithSameId()
        {
            var context = new TestTransactionContext();
              context.Transactions.Add(new Transaction { TransactionId = 1, Description = "Demo1", TransactionAmount = 1.23M });
              context.Transactions.Add(new Transaction { TransactionId = 2, Description = "Demo2", TransactionAmount = 2.34M });
              context.Transactions.Add(new Transaction { TransactionId = 3, Description = "Demo3", TransactionAmount = 34.45M });
              context.Transactions.Add(new Transaction { TransactionId = 4, Description = "Demo4", TransactionAmount = 456.78M });
              var controller = new TransactionsController(context);

              var result = controller.DeleteTransaction(1);
              Assert.IsInstanceOfType(result, typeof(OkResult));
        }
        public void DeleteTransaction_ShouldNotFindTransaction()
        {
            var context = new TestTransactionContext();
              context.Transactions.Add(new Transaction { TransactionId = 1, Description = "Demo1", TransactionAmount = 1.23M });
              context.Transactions.Add(new Transaction { TransactionId = 2, Description = "Demo2", TransactionAmount = 2.34M });
              context.Transactions.Add(new Transaction { TransactionId = 3, Description = "Demo3", TransactionAmount = 34.45M });
              context.Transactions.Add(new Transaction { TransactionId = 4, Description = "Demo4", TransactionAmount = 456.78M });
              var controller = new TransactionsController(context);

              try
              {
            var result = controller.DeleteTransaction(999);
              }
              catch (HttpResponseException ex)
              {
            Assert.AreEqual(ex.Response.StatusCode, HttpStatusCode.BadRequest, "Transaction not found");
              }
        }
 public ActionResult Delete(int id)
 {
     TransactionsController tc = new TransactionsController(db);
       var result = tc.DeleteTransaction(id);
       return RedirectToAction("Index");
 }