public void Get_userExists_shouldReturnUser() { var expected = CreateUser(); var mockRepository = new Mock<IUserRepository>(); mockRepository.Setup(x => x.Get(expected.Id.Value)).Returns(expected); var controller = new UserController {UserRepository = mockRepository.Object}; var actual = controller.Get(expected.Id.Value); Assert.AreEqual(expected, actual); }
public void Get_allUsersExist_shouldReturnUsers() { var expected = CreateUser(); var mockRepository = new Mock<IUserRepository>(); mockRepository.Setup(x => x.GetAll()).Returns(new[]{ expected, expected }); var controller = new UserController {UserRepository = mockRepository.Object}; var actual = controller.Get(); Assert.AreEqual(expected, actual.First()); }