public void Get_User_Should_Return_User_With_SameID() { var context = new TestUserContext(); context.Users.Add(GetDemoUser()); var controller = new UsersController(context); var result = controller.GetUser(3) as OkNegotiatedContentResult<User>; Assert.IsNotNull(result); Assert.AreEqual(3, result.Content.UserId); }
public void Delete_User_Should_ReturnOK() { var context = new TestUserContext(); var item = GetDemoUser(); context.Users.Add(item); var controller = new UsersController(context); var result = controller.DeleteUser(3) as OkNegotiatedContentResult<User>; Assert.IsNotNull(result); Assert.AreEqual(item.UserId, result.Content.UserId); }
public void Get_Users_Should_Return_AllUsers() { var context = new TestUserContext(); context.Users.Add(new User { UserId = 1, Name = "Demo1", Cpf = "123654", End="Rua Silva", Phone="2759164"}); context.Users.Add(new User { UserId = 2, Name = "Demo2", Cpf = "123563", End = "Rua Almeida", Phone = "2759164" }); context.Users.Add(new User { UserId = 3, Name = "Demo3", Cpf = "1234569", End = "Rua Casda", Phone = "2759164" }); var controller = new UsersController(context); var result = controller.GetUsers() as TestUserDbSet; Assert.IsNotNull(result); Assert.AreEqual(3, result.Local.Count); }