public async Task CreateBankAccountWithInitialDepositTest() { var result = await _controller.PostBankAccount(500); var contentResult = result as CreatedAtRouteNegotiatedContentResult <BankAccount>; Assert.IsNotNull(contentResult); Assert.AreEqual(3, _fakeContext.BankAccounts.Count()); Assert.AreEqual(_fakeContext.BankAccounts.ElementAt(2), contentResult.Content); Assert.AreEqual(500, contentResult.Content.Balance); }
public void CreateBankAccount() { var context = serviceProvider.GetRequiredService <DataContext>(); var controller = new BankAccountsController(context); controller.PostBankAccount(bankAccount1); var createdBankAccount = controller.GetBankAccountById(bankAccount1.Id).Result.Value; Assert.Equal(createdBankAccount, bankAccount1); }
private async Task <BankAccount> GetDemoBankAccount() { var bankAccount = new BankAccount() { Id = Guid.NewGuid(), Number = 1234, Cpf = 00200200202, Creation = DateTime.Now }; BankAccountsController controller = new BankAccountsController(new TestWebApiBankAccountContext()); var resultBankAccount = await controller.PostBankAccount(bankAccount.Cpf) as OkNegotiatedContentResult <string>; var resultBankAccountBalance = await this.Controller.PostBankAccountBalance(bankAccount.Number, 230, "sum") as OkNegotiatedContentResult <string>; // pegar o número da conta criado //if (result != null) // bankAccount.Number = Convert.ToInt32(result.Content.Replace(" ", ";").Split(';')[2]); return(bankAccount); }