public async Task GetByIdsWithTimeSeries()
        {
            var utcNow       = SystemClock.UtcNow;
            var yesterdayLog = await _dailyRepository.AddAsync(LogEventGenerator.Generate(createdUtc: utcNow.AddDays(-1)));

            Assert.NotNull(yesterdayLog?.Id);

            var nowLog = await _dailyRepository.AddAsync(LogEventGenerator.Default);

            Assert.NotNull(nowLog?.Id);

            var results = await _dailyRepository.GetByIdsAsync(new[] { yesterdayLog.Id, nowLog.Id });

            Assert.NotNull(results);
            Assert.Equal(2, results.Count);
        }
Exemplo n.º 2
0
        public async Task SearchByQueryWithTimeSeriesAsync()
        {
            var utcNow       = SystemClock.UtcNow;
            var yesterdayLog = await _dailyRepository.AddAsync(LogEventGenerator.Generate(ObjectId.GenerateNewId(utcNow.AddDays(-1)).ToString(), createdUtc: utcNow.AddDays(-1), companyId: "1234567890"), o => o.ImmediateConsistency());

            Assert.NotNull(yesterdayLog?.Id);

            var nowLog = await _dailyRepository.AddAsync(LogEventGenerator.Default, o => o.ImmediateConsistency());

            Assert.NotNull(nowLog?.Id);

            var results = await _dailyRepository.GetByIdsAsync(new[] { yesterdayLog.Id, nowLog.Id });

            Assert.NotNull(results);
            Assert.Equal(2, results.Count);

            var searchResults = await _dailyRepository.SearchAsync(new RepositoryQuery().Company("test"));

            Assert.Equal(0, searchResults.Total);

            searchResults = await _dailyRepository.SearchAsync(new RepositoryQuery().Company(yesterdayLog.CompanyId));

            Assert.Equal(1, searchResults.Total);

            searchResults = await _dailyRepository.SearchAsync(new RepositoryQuery().Company(yesterdayLog.CompanyId).DateRange(utcNow.Subtract(TimeSpan.FromHours(1)), utcNow, "created"));

            Assert.Equal(0, searchResults.Total);

            searchResults = await _dailyRepository.SearchAsync(new RepositoryQuery().Id(yesterdayLog.Id));

            Assert.Equal(1, searchResults.Total);
        }
        public async Task AddCollectionWithTimeSeriesAsync()
        {
            var utcNow       = SystemClock.UtcNow;
            var yesterdayLog = LogEventGenerator.Generate(ObjectId.GenerateNewId(utcNow.AddDays(-1)).ToString(), createdUtc: utcNow.AddDays(-1));
            var nowLog       = LogEventGenerator.Default;

            var logs = new List <LogEvent> {
                yesterdayLog, nowLog
            };
            await _dailyRepository.AddAsync(logs, o => o.ImmediateConsistency());

            var results = await _dailyRepository.GetByIdsAsync(new List <string> {
                yesterdayLog.Id, nowLog.Id
            });

            Assert.Equal(logs, results.OrderBy(d => d.CreatedUtc).ToList());

            var getAllResults = await _dailyRepository.GetAllAsync();

            Assert.Equal(logs, getAllResults.Documents.OrderBy(d => d.CreatedUtc).ToList());
        }