public async Task PostTransaction_WithValidAccount_Returns200OKRefactored()
        {
            //Arrange
            var builder         = new TransactionControllerBuilder();
            var controller      = builder.Build();
            var transactionInfo = GetTestableTransactionInfo();
            //Act
            var actionResult = await controller.PostTransaction(transactionInfo);

            //Assert
            actionResult.Should().BeOfType(typeof(OkNegotiatedContentResult <int>));
        }
        public async Task PostTransaction_WithValidAccount_SummarisedTransaction()
        {
            //Arrange
            var builder         = new TransactionControllerBuilder();
            var service         = builder.DefaultAccountTransactionService();
            var controller      = builder.WithAccountTransactionService(service.Object).Build();
            var transactionInfo = GetTestableTransactionInfo();
            //Act
            var actionREsult = await controller.PostTransaction(transactionInfo);

            //Assert
            service.Verify(x => x.SummarizeTransactions("1"), Times.Once, "We need to make sure the account is summarised");
        }
        public async Task PostTransaction_OnError_DisposesService()
        {
            //Arrange
            var builder = new TransactionControllerBuilder();
            var service = builder.DefaultAccountTransactionService();

            service.Setup(x => x.CommitTransaction(It.IsAny <TransactionInfo>()))
            .Throws(new Exception("Test Exception"));
            var controller = builder.WithAccountTransactionService(service.Object).Build();
            //Act
            var actionResult = await controller.PostTransaction(new TransactionInfo());

            //Assert
            service.Verify(x => x.Dispose(), Times.Once, "the dispose method needs to be called once to clean up resources");
        }
        public async Task PostTransaction_WithInvalidAccount_ReturnedNotFound()
        {
            //Arrange
            var builder = new TransactionControllerBuilder();
            var service = builder.DefaultAccountTransactionService();

            service.Setup(x => x.CommitTransaction(It.IsAny <TransactionInfo>())).Throws <ArgumentException>();

            var controller = builder
                             .WithAccountTransactionService(service.Object)
                             .Build();
            var transactionInfo = GetTestableTransactionInfo();

            //Act
            var actionResult = await controller.PostTransaction(transactionInfo);

            var content = actionResult as NegotiatedContentResult <string>;

            //Assert
            content.StatusCode.Should().Be(HttpStatusCode.NotFound);
        }