public async Task CreateUser_Should_Trigger_SendEmail_When_Add_Succeed() { FakeCreateUserAsyncReturnTrue(); var dto = new CreateUserDto { UserName = "******", Password = "******", Email = "*****@*****.**" }; var(code, msg) = await _biz.CreateUserAsync(dto); A.CallTo(() => _notifyBiz.SendEmail(dto.Email)).MustHaveHappened(); }
public async Task <(int code, string msg)> CreateUserAsync(CreateUserDto dto) { // ignore some params check... // here can use AutoMapper to impore var userInfo = dto.GetUserInfo(); var isStrongPassword = userInfo.CheckIsStrongPassword(); if (!isStrongPassword) { return(1001, "password is too weak"); } var isSucc = await _repo.CreateUserAsync(userInfo); if (isSucc) { await _notifyBiz.SendEmail(userInfo.Email); _logger.LogInformation("create userinfo succeed.."); return(0, "ok"); } else { _logger.LogWarning("create userinfo fail.."); return(9000, "error"); } }