public void GetUser_ShouldReturnUserWithSameID() { var context = new TestUserContext(); context.Users.Add(GetDemoUser()); var controller = new UserController(context); var result = controller.GetUser(3) as OkNegotiatedContentResult <User>; Assert.IsNotNull(result); Assert.AreEqual(3, result.Content.Id); }
public void DeleteUser_ShouldReturnOK() { var context = new TestUserContext(); var item = GetDemoUser(); context.Users.Add(item); var controller = new UserController(context); var result = controller.DeleteUser(3) as OkNegotiatedContentResult <User>; Assert.IsNotNull(result); Assert.AreEqual(item.Id, result.Content.Id); }
public void GetUsers_ShouldReturnAllUsers() { var context = new TestUserContext(); context.Users.Add(new User { Id = 1, Name = "Fede", LastName = "GOn" }); context.Users.Add(new User { Id = 2, Name = "Sergio", LastName = "DFD" }); context.Users.Add(new User { Id = 3, Name = "Pablo", LastName = "dtyty" }); var controller = new UserController(context); var result = controller.GetUsers() as TestUserDbSet; Assert.IsNotNull(result); Assert.AreEqual(3, result.Local.Count); }