public void GetUserHistoryByUserId_IncludesHistory() { // Arrange SOVAContext databaseContext = new SOVAContext(_connectionString); UserHistoryRepository userHistoryRepository = new UserHistoryRepository(databaseContext); User testUser = EnsureTestUserExistsThroughContext_ReturnsTestUser(); databaseContext.SearchResults.FromSqlRaw("SELECT * FROM best_match_weighted({0}, {1})", testUser.Id, "testing"); // Act IEnumerable <UserHistory> histories = userHistoryRepository.GetUserHistoryByUserId(testUser.Id); // Assert Assert.All(histories, (history) => Assert.NotNull(history.History)); }
public void GetUserHistoryByUserId_ValidArguments(int pageSize, int pageNumber) { // Arrange SOVAContext databaseContext = new SOVAContext(_connectionString); UserHistoryRepository userHistoryRepository = new UserHistoryRepository(databaseContext); User testUser = EnsureTestUserExistsThroughContext_ReturnsTestUser(); databaseContext.SearchResults.FromSqlRaw("SELECT * from best_match_weighted({0}, {1})", testUser.Id, "testing"); IEnumerable <UserHistory> expectedHistories = databaseContext.UserHistory .Where(userHistory => userHistory.UserId == testUser.Id); // Act IEnumerable <UserHistory> actualHistories = userHistoryRepository.GetUserHistoryByUserId(testUser.Id); // Assert Assert.Equal(expectedHistories, actualHistories); }