public void should_return_notExist_when_id_not_Exist() { // Arrange var expectedUserId = 2; var expectedResult = false; UserRepositoryMock .Setup(i => i.IsExistAsync(expectedUserId)).ReturnsAsync(expectedResult); // Act var result = UserServiceUnderTest.IsExistAsync(expectedUserId); // Assert Assert.False(result.Result == true); }
public void Should_return_nullexception_when_user_is_null() { //Arrange UserUpdate UserUpdate = null; UserRepositoryMock .Setup(i => i.UpdateAsync(UserUpdate)) .ThrowsAsync(new ArgumentNullException("User is null")); //Act var result = UserServiceUnderTest.UpdateAsync(UserUpdate); //Assert Assert.ThrowsAsync <ArgumentNullException>(async() => await result); }
public async Task Deve_retornar_null_se_o_usuario_nao_existir() { // Arrange var userId = Guid.NewGuid(); UserRepositoryMock .Setup(x => x.GetOneByIdAsync(userId)) .ReturnsAsync(default(User)); // Act var result = await ServiceUnderTest.GetOneByIdAsync(userId); // Assert Assert.Null(result); }
public void Should_return_null_when_user_notExist() { //Arrange var existingUserId = 6; User user = null; UserRepositoryMock .Setup(i => i.ReadOneAsync(existingUserId)) .ReturnsAsync(user); //Act var result = UserServiceUnderTest.ReadOneAsync(existingUserId); //Assert Assert.Null(result.Result); }
public void Should_return_User_when_user_exist() { //Arrange var existingUserId = 6; var expectedUser = Data; UserRepositoryMock .Setup(i => i.ReadOneAsync(existingUserId)) .ReturnsAsync(expectedUser); //Act var result = UserServiceUnderTest.ReadOneAsync(existingUserId); //Assert Assert.Same(expectedUser, result.Result); }
public async Task Deve_retornar_o_usuario_esperado() { // Arrange var userId = Guid.NewGuid(); var expectedUser = new User { Id = userId, Name = "Gabriel Meyer", Email = "*****@*****.**" }; UserRepositoryMock .Setup(x => x.GetOneByIdAsync(userId)) .ReturnsAsync(expectedUser); // Act var result = await ServiceUnderTest.GetOneByIdAsync(userId); // Assert Assert.Same(expectedUser, result); }
public void Should_return_object_when_user_created() { //Arrange User user = Data; var resultObject = new { Id = 1, AuthRefId = "cfd5935c-7a60-40ea-8a27-e7452e50fa5f", PhotoUri = "http://photouri/23298873" }; UserRepositoryMock .Setup(i => i.CreateAsync(user)) .ReturnsAsync(resultObject); //Act var result = UserServiceUnderTest.CreateAsync(user); //Assert Assert.Same(resultObject, result.Result); }
public async Task Deve_retornar_todos_os_usuario() { // Arrange var expectedUsers = new ReadOnlyCollection <User>(new List <User> { new User { Name = "Gabriel Meyer", Email = "*****@*****.**" }, new User { Name = "Renato Rezende", Email = "*****@*****.**" } }); UserRepositoryMock .Setup(x => x.GetAllAsync()) .ReturnsAsync(expectedUsers); // Act var result = await ServiceUnderTest.GetAllAsync(); // Assert Assert.Same(expectedUsers, result); }