public void GetUserId() { // arrange var users = new Mock<IUsersRepository>(); var forms = new Mock<IFormsAuthentication>(); var hash = new HashService(); var service = new AuthenticationService(users.Object, forms.Object, hash); users.Setup(u => u.Users).Returns(new List<User> { new User { Email = "*****@*****.**", PasswordHash = hash.CreateMD5Hash("111"), Id = 1, Temp = false } }.AsQueryable()); // act var id = service.GetUserIdByEmail("*****@*****.**"); // assert Assert.That(id, Is.EqualTo(1)); }