public async Task ScriptPatchAllWithNoCacheAsync() { var utcNow = SystemClock.UtcNow; var logs = new List <LogEvent> { LogEventGenerator.Generate(ObjectId.GenerateNewId(utcNow.AddDays(-1)).ToString(), createdUtc: utcNow.AddDays(-1), companyId: "1"), LogEventGenerator.Generate(createdUtc: utcNow, companyId: "1"), LogEventGenerator.Generate(createdUtc: utcNow, companyId: "2"), }; await _dailyRepositoryWithNoCaching.AddAsync(logs, o => o.ImmediateConsistency()); Assert.Equal(3, await _dailyRepositoryWithNoCaching.IncrementValueAsync(q => q.Id(logs.Select(l => l.Id).ToArray()))); var results = await _dailyRepositoryWithNoCaching.GetAllByCompanyAsync("1"); Assert.Equal(2, results.Documents.Count); foreach (var document in results.Documents) { Assert.Equal("1", document.CompanyId); Assert.Equal(1, document.Value); } await _dailyRepositoryWithNoCaching.SaveAsync(logs, o => o.ImmediateConsistency()); results = await _dailyRepositoryWithNoCaching.GetAllByCompanyAsync("1"); Assert.Equal(2, results.Documents.Count); foreach (var document in results.Documents) { Assert.Equal("1", document.CompanyId); Assert.Equal(0, document.Value); } }
public async Task ScriptPatchAll() { var utcNow = SystemClock.UtcNow; var logs = new List <LogEvent> { LogEventGenerator.Generate(ObjectId.GenerateNewId(utcNow.AddDays(-1)).ToString(), createdUtc: utcNow.AddDays(-1), companyId: "1"), LogEventGenerator.Generate(createdUtc: utcNow, companyId: "1"), LogEventGenerator.Generate(createdUtc: utcNow, companyId: "2"), }; await _dailyRepository.AddAsync(logs, addToCache : true); Assert.Equal(5, _cache.Count); Assert.Equal(0, _cache.Hits); Assert.Equal(0, _cache.Misses); await _client.RefreshAsync(); Assert.Equal(3, await _dailyRepository.IncrementValueAsync(logs.Select(l => l.Id).ToArray())); Assert.Equal(2, _cache.Count); Assert.Equal(0, _cache.Hits); Assert.Equal(0, _cache.Misses); await _client.RefreshAsync(); var results = await _dailyRepository.GetAllByCompanyAsync("1"); Assert.Equal(2, results.Documents.Count); foreach (var document in results.Documents) { Assert.Equal("1", document.CompanyId); Assert.Equal(1, document.Value); } await _dailyRepository.SaveAsync(logs, addToCache : true); await _client.RefreshAsync(); results = await _dailyRepository.GetAllByCompanyAsync("1"); Assert.Equal(2, results.Documents.Count); foreach (var document in results.Documents) { Assert.Equal("1", document.CompanyId); Assert.Equal(0, document.Value); } }