Exemple #1
0
        public async Task ShouldCallAddMethodInRepositoryProperly()
        {
            var sut = new CreateAccountUseCase(_mockAccountRepository.Object);

            await sut.Run("Account");

            _mockAccountRepository.Verify(x => x.Add(It.IsAny <Account>()));
        }
Exemple #2
0
        public async Task ShouldThrowApplicationExceptionWhenAccountNameIsNullOrEmpty()
        {
            await Assert.ThrowsAsync <ApplicationException>(async() =>
            {
                var sut = new CreateAccountUseCase(_mockAccountRepository.Object);

                await sut.Run("");
            });
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 public AccountController(ILogger <AccountController> logger, CreateAccountUseCase useCase)
 {
     _logger  = logger;
     _useCase = useCase;
 }