public async Task ShouldCallAddMethodInRepositoryProperly() { var sut = new CreateAccountUseCase(_mockAccountRepository.Object); await sut.Run("Account"); _mockAccountRepository.Verify(x => x.Add(It.IsAny <Account>())); }
public async Task ShouldThrowApplicationExceptionWhenAccountNameIsNullOrEmpty() { await Assert.ThrowsAsync <ApplicationException>(async() => { var sut = new CreateAccountUseCase(_mockAccountRepository.Object); await sut.Run(""); }); }
public async Task ShouldHasANameAndBalanceZero() { var expectedAccountName = "Use Case Account"; decimal expectedBalance = 0; var sut = new CreateAccountUseCase(_mockAccountRepository.Object); var actualAccountOutput = await sut.Run(expectedAccountName); Assert.Equal(expectedAccountName, actualAccountOutput.AccountName); Assert.Equal(expectedBalance, actualAccountOutput.AccountBalance); }
public async Task QuandOnVeutCreerLeCompte() { this.repository = Substitute.For <IAccountRepository>(); this.repository.GetAsync(Arg.Any <AccountId>()).Returns(this.existingAccountFromId); this.repository.IdExists(Arg.Any <AccountId>()).Returns((existingAccountFromId != null)); this.repository.NameExists(Arg.Any <AccountName>()).Returns((existingAccountFromName != null)); var createUseCase = new CreateAccountUseCase(repository); var accountController = new AccountController(Substitute.For <IGetAccountsUseCase>(), Substitute.For <IArchiveAccountUseCase>(), createUseCase); var accountToCreate = AccountDto.FromDomain(this.futureAccount); this.result = await accountController.CreateAsync(accountToCreate); }
public AccountController(ILogger <AccountController> logger, CreateAccountUseCase useCase) { _logger = logger; _useCase = useCase; }