예제 #1
0
        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);
        }
예제 #2
0
        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());
        }