public async Task Should_Returns_User_When_SuccessOnGetUser() { var command = new GetUserByIdQuery { Id = OBJECT_ID }; _authRepository.GetUserById(Arg.Any <string>()).Returns(new User(OBJECT_ID, NAME, EMAIL, PASSWORD, PHONES, DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow, TOKEN)); var actual = await _handler.Handle(command, CancellationToken.None); Assert.NotNull(actual); Assert.True(actual.IsSuccess); Assert.NotNull(actual.Value.User); Assert.Equal(actual.Value.User.Email, EMAIL); Assert.Equal(actual.Value.User.Name, NAME); Assert.Equal(actual.Value.User.Phones.Count, PHONES.Count); }
public async void SouldReturnSuccess_WhenListUser() { // arrange var(repo, context) = GetRepository(); var entity = new UserEntity { Email = "*****@*****.**", Name = "test1", Password = "******" }; _ = await repo.Save(entity); var comando = new GetUserByIdCommand { Id = 1 }; var handler = new GetUserByIdHandler(repo); // act var ret = await handler.Handle(comando, CancellationToken.None); // assert var result = context.UserEntityDb.Find(comando.Id); Assert.True(ret.Data.Email == result.Email); }