public ReadOnlyRepositoryTests(ITestOutputHelper output) : base(output) { _identityRepository = new IdentityRepository(_configuration); _dailyRepository = new DailyLogEventRepository(_configuration); _employeeRepository = new EmployeeRepository(_configuration); RemoveDataAsync().GetAwaiter().GetResult(); }
public async Task GetByDateBasedIndex() { await _configuration.DailyLogEvents.ConfigureAsync(); var indexes = await _client.GetIndicesPointingToAliasAsync(_configuration.DailyLogEvents.Name); Assert.Equal(0, indexes.Count); var alias = await _client.GetAliasAsync(descriptor => descriptor.Alias(_configuration.DailyLogEvents.Name)); _logger.Trace(() => alias.GetRequest()); Assert.False(alias.IsValid); Assert.Equal(0, alias.Indices.Count); var utcNow = SystemClock.UtcNow; var repository = new DailyLogEventRepository(_configuration); var logEvent = await repository.AddAsync(LogEventGenerator.Generate(createdUtc: utcNow)); Assert.NotNull(logEvent?.Id); logEvent = await repository.AddAsync(LogEventGenerator.Generate(createdUtc: utcNow.SubtractDays(1))); Assert.NotNull(logEvent?.Id); await _client.RefreshAsync(); alias = await _client.GetAliasAsync(descriptor => descriptor.Alias(_configuration.DailyLogEvents.Name)); _logger.Trace(() => alias.GetRequest()); Assert.True(alias.IsValid); Assert.Equal(2, alias.Indices.Count); indexes = await _client.GetIndicesPointingToAliasAsync(_configuration.DailyLogEvents.Name); Assert.Equal(2, indexes.Count); await repository.RemoveAllAsync(); await _client.RefreshAsync(); Assert.Equal(0, await repository.CountAsync()); }