public void GetUserBySessionKey_WhenValidSessionKey_ShouldReturnUser() { Mock<IUowData> mock = new Mock<IUowData>(); mock.Setup(m => m.Users.GetAll()).Returns(new User[] { new User { SessionKey = "other" }, new User { SessionKey = "other" }, new User { SessionKey = "100448Sitruv4IfYOGRSp6PqmxNFYr11vvZKQpCcLzmWThbTI3" }, new User { SessionKey = "other" }, }.AsQueryable()); BaseService userService = new BaseService(mock.Object); User user = userService.GetUserBySessionKey("100448Sitruv4IfYOGRSp6PqmxNFYr11vvZKQpCcLzmWThbTI3"); Assert.AreEqual(user.SessionKey, "100448Sitruv4IfYOGRSp6PqmxNFYr11vvZKQpCcLzmWThbTI3"); }
public void GetUserBySessionKey_WhenValidSessionKeyButNoUsersWithHim_ShouldThrowException() { Mock<IUowData> mock = new Mock<IUowData>(); mock.Setup(m => m.Users.GetAll()).Returns(new User[] { new User { SessionKey = "other" }, new User { SessionKey = "other" }, new User { SessionKey = "other" }, new User { SessionKey = "other" }, }.AsQueryable()); BaseService userService = new BaseService(mock.Object); userService.GetUserBySessionKey("100448Sitruv4IfYOGRSp6PqmxNFYr11vvZKQpCcLzmWThbTI3"); }