Пример #1
0
        public void If_the_request_is_successful_then_an_ok_no_content_response_should_be_returned()
        {
            Given
            .BankAccount_has_been_created()
            .GetResult(out BankingStoryData bankAccount);

            When
            .Delete($"api/bankaccounts/{bankAccount.BankAccountId}");

            Then.Response.ShouldBe.NoContent();
        }
Пример #2
0
        public void Given_that_a_bank_account_has_been_created()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Fred")
            .GetResult(out BankingStoryData bankAccount);

            When
            .Get($"{ApiBankaccounts}/{bankAccount.BankAccountId}");

            Then.Response
            .ShouldBe
            .Ok <BankAccount>();
        }
Пример #3
0
        public void If_the_deposit_is_successful_then_an_ok_response_should_be_returned()
        {
            Given
            .BankAccount_has_been_created()
            .GetResult(out BankingStoryData bankAccount);

            When
            .Post($"api/bankaccounts/{bankAccount.BankAccountId}/deposits", new Deposit {
                Amount = 100
            });

            Then.Response.ShouldBe.Ok();
        }
Пример #4
0
        public void Then_the_snapshot_should_be_correct()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Fred")
            .GetResult(out BankingStoryData bankAccount);

            When
            .Get($"{ApiBankaccounts}/{bankAccount.BankAccountId}");

            MyScenario.Then
            .Snapshot()
            .Match <BankAccount>(options => options.IgnoreField <int>("Id"));
        }
Пример #5
0
        public void Then_the_snapshot_customer_should_be_correct(string customerName)
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = customerName)
            .GetResult(out BankingStoryData bankAccount);

            When
            .Get($"{ApiBankaccounts}/{bankAccount.BankAccountId}");

            Then
            .Snapshot(customerName)
            .Match <BankAccount>(options => options.IgnoreField("Id"));
        }
Пример #6
0
        public void Then_the_customer_name_should_be_correct()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Fred")
            .GetResult(out BankingStoryData bankAccount);

            When
            .Get($"{ApiBankaccounts}/{bankAccount.BankAccountId}");

            Then.Response
            .ShouldBe
            .Ok <BankAccount>()
            .CustomerName
            .ShouldBe("Fred");
        }
Пример #7
0
        public void When_updating_a_bank_account_the_response_should_be_no_content()
        {
            Given
            .BankAccount_has_been_created()
            .GetResult(out BankingStoryData bankAccount);

            When
            .Put($"api/bankaccounts/{bankAccount.BankAccountId}", new BankAccount
            {
                CustomerName = "New Name"
            });

            Then.Response
            .ShouldBe
            .NoContent();
        }
        public void Then_the_customer_name_should_be_correct()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Fred")
            .GetResult(out BankingStoryData bankAccount);

            When
            .Get($"{ApiBankaccounts}/{bankAccount.BankAccountId}", message =>
            {
                message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "blah blah");
            });

            Then.Response
            .ShouldBe
            .Ok <BankAccount>()
            .CustomerName
            .ShouldBe("Fred");
        }
Пример #9
0
        public void Given_that_multiple_deposits_have_been_made_then_the_balance_should_be_correct()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Fred")
            .Deposit_has_been_made(storyData => new Deposit {
                Amount = 50
            })
            .Deposit_has_been_made(50)
            .Withdrawal_has_been_made(25)
            .GetResult(out BankingStoryData bankAccount);

            When
            .Get($"{ApiBankaccounts}/{bankAccount.BankAccountId}");

            Then.Response
            .ShouldBe
            .Ok <BankAccount>()
            .Balance
            .ShouldBe(75);
        }
Пример #10
0
        If_a_withdrawal_is_requested_but_there_are_insufficient_funds_then_a_bad_request_should_be_returned()
        {
            Given
            .BankAccount_has_been_created()
            .Deposit_has_been_made((storyData) => new Deposit {
                Amount = 100
            })
            .GetResult(out BankingStoryData bankAccount);

            When
            .Post($"api/bankaccounts/{bankAccount.BankAccountId}/withdrawals", new Withdrawal {
                Amount = 1000
            });

            Then
            .Response
            .ShouldBe
            .BadRequest
            .WithMessage("Insufficient Funds to make withdrawal.");
        }
Пример #11
0
        public void Transfer_extracting_result_multiple_times()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Rich Person")
            .GetResult(out BankingStoryData richBankAccount)
            .Deposit_has_been_made((storyData) => new Deposit
            {
                Id     = richBankAccount.BankAccountId,
                Amount = 100
            })
            .BankAccount_has_been_created(account => account.CustomerName = "Poor Person Person")
            .GetResult(out BankingStoryData poorBankAccount);

            When
            .Post("api/transfers", new Transfer
            {
                FromBankAccountId = richBankAccount.BankAccountId,
                ToBankAccountId   = poorBankAccount.BankAccountId,
                Amount            = 100
            });

            Then.Response.ShouldBe.Created();
        }
Пример #12
0
        public void If_the_the_transfer_is_successful_then_an_ok_response_should_be_returned()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Rich Person")
            .Deposit_has_been_made((storyData) => new Deposit {
                Amount = 100
            })
            .GetResult(out BankingStoryData richBankAccount);

            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Poor Person Person")
            .GetResult(out BankingStoryData poorBankAccount);

            When
            .Post("api/transfers", new Transfer
            {
                FromBankAccountId = richBankAccount.BankAccountId,
                ToBankAccountId   = poorBankAccount.BankAccountId,
                Amount            = 100
            });

            Then.Response.ShouldBe.Created();
        }
Пример #13
0
        public void Given_that_a_mixture_of_deposits_and_withdrawals_have_been_made_then_the_balance_should_be_correct()
        {
            Given
            .BankAccount_has_been_created(account => account.CustomerName = "Fred")
            .Deposit_has_been_made(bankingStoryData =>
            {
                Assert.NotEqual(0, bankingStoryData.BankAccountId);
                return(new Deposit {
                    Amount = 100
                });
            })
            .Withdrawal_has_been_made(50)
            .Deposit_has_been_made(25)
            .GetResult(out BankingStoryData bankAccount);

            When
            .Get($"{ApiBankaccounts}/{bankAccount.BankAccountId}");

            Then.Response
            .ShouldBe
            .Ok <BankAccount>()
            .Balance
            .ShouldBe(75);
        }