private static void SeedInternalErrorLogEntries(LoggingDbContext context) { if (!context.InternalErrorLogEntries.Any()) { context.InternalErrorLogEntries.AddRange(InternalErrorLogEntryFaker.Generate()); } if (!context.AccountLogEntries.Any()) { context.AccountLogEntries.AddRange(AccountLogEntryFaker.Generate()); } if (!context.PaymentLogEntries.Any()) { context.PaymentLogEntries.AddRange(PaymentLogEntryFaker.Generate()); } if (!context.SearchQueryLogEntries.Any()) { context.SearchQueryLogEntries.AddRange(SearchQueryLogEntryFaker.Generate()); } if (!context.TicketActionLogEntries.Any()) { context.TicketActionLogEntries.AddRange(TicketActionLogEntryFaker.Generate()); } if (!context.TicketDealLogEntries.Any()) { context.TicketDealLogEntries.AddRange(TicketDealLogEntryFaker.Generate()); } context.SaveChanges(); }
public async Task ShouldGetFilteredEntries(string userId, string userName, string filterInfo, DateTime?dateFrom = null, DateTime?dateTo = null) { // Arrange Context.SearchQueryLogEntries.AddRange(SearchQueryLogEntryFaker.Generate(10)); Context.SearchQueryLogEntries.Add(new SearchQueryLogEntryDbModel { UserId = "alexpvt", SearchCriterium = "opera aida", FilterInfo = "theaters, opera", EventDate = DateTimeNow }); await Context.SaveChangesAsync(); var filter = new SearchQueryLogsFilter() { UserId = userId, SearchCriterium = userName, FilterInfo = filterInfo, DateFrom = dateFrom, DateTo = dateTo }; // Act var entries = await _searchLogService.GetLogsAsync(filter); // Assert entries.Count().ShouldBeEqualTo(1); var entry = entries.Single(); entry.UserId.ShouldBeEqualTo("alexpvt"); entry.SearchCriterium.ShouldBeEqualTo("opera aida"); entry.FilterInfo.ShouldBeEqualTo("theaters, opera"); entry.EventDate.ShouldBeEqualTo(DateTimeNow); }