public async Task Unit_CreateNewAccount_ExpectAccountInResultAndRepository() { var newAccountName = "Johnny"; AccountCreatorService creator = new AccountCreatorService(_mockLogger.Object, newAccountName, _accountRepo); ServiceResult result = await creator.CreateAccount(); result.Should().NotBeNull(); AccountInsertResultDto newAccount = JsonConvert.DeserializeObject <AccountInsertResultDto>(result.ContentResult); newAccount.Should().NotBeNull(); newAccount.Name.Should().Be(newAccountName); newAccount.AccountId.Should().BeGreaterThan(0); Account newAccountFromDb = await _accountRepo.GetAsync(newAccount.AccountId); newAccountFromDb.Should().NotBeNull(); newAccountFromDb.Name.Should().Be(newAccount.Name); newAccountFromDb.Id.Should().Be(newAccount.AccountId); }
public async Task <IActionResult> CreateNewAccount([FromBody] AccountInsertDto objDto) { AccountCreatorService creator = new AccountCreatorService(_logger, objDto.Name, _accountRepo); return(this.GetActionResultFromServiceResult(await creator.CreateAccount())); }