示例#1
0
        public async Task CanCacheFindResultAsync()
        {
            var employee = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(age: 20), o => o.ImmediateConsistency());

            var employees = await _employeeRepository.GetAllByAgeAsync(20);

            Assert.Equal(1, employees.Documents.Count);

            string json    = JsonConvert.SerializeObject(employees);
            var    results = JsonConvert.DeserializeObject <FindResults <Employee> >(json);

            Assert.NotNull(results);
            Assert.Equal(1, results.Documents.Count);
        }
        public async Task CanCacheFindResult()
        {
            var employee = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(age: 20));

            await _client.RefreshAsync();

            var employees = await _employeeRepository.GetAllByAgeAsync(20);

            Assert.Equal(1, employees.Documents.Count);

            var json    = JsonConvert.SerializeObject(employees);
            var results = JsonConvert.DeserializeObject <FindResults <Employee> >(json);

            Assert.NotNull(results);
            Assert.Equal(1, results.Documents.Count);
        }
示例#3
0
        public async Task GetByAgeAsync()
        {
            var employee19 = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(age: 19), o => o.ImmediateConsistency());

            var employee20 = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(age: 20), o => o.ImmediateConsistency());

            var results = await _employeeRepository.GetAllByAgeAsync(employee19.Age);

            Assert.Equal(1, results.Total);
            Assert.Equal(employee19, results.Documents.First());

            results = await _employeeRepository.GetAllByAgeAsync(employee20.Age);

            Assert.Equal(1, results.Total);
            Assert.Equal(employee20, results.Documents.First());
        }
示例#4
0
        public async Task GetByAgeAsync()
        {
            var employee19 = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(age: 19));

            var employee20 = await _employeeRepository.AddAsync(EmployeeGenerator.Generate(age: 20));

            await _client.RefreshAsync();

            var results = await _employeeRepository.GetAllByAgeAsync(employee19.Age);

            Assert.Equal(1, results.Total);
            Assert.Equal(employee19, results.Documents.First());

            results = await _employeeRepository.GetAllByAgeAsync(employee20.Age);

            Assert.Equal(1, results.Total);
            Assert.Equal(employee20, results.Documents.First());
        }
        public async Task GetByAgeAsync()
        {
            await RemoveDataAsync();

            var employee19 = await _repository.AddAsync(EmployeeGenerator.Generate(age: 19));

            var employee20 = await _repository.AddAsync(EmployeeGenerator.Generate(age: 20));

            await _client.RefreshAsync();

            var result = await _repository.GetByAgeAsync(employee19.Age);

            Assert.Equal(employee19.ToJson(), result.ToJson());

            var results = await _repository.GetAllByAgeAsync(employee20.Age);

            Assert.Equal(1, results.Total);
            Assert.Equal(employee20.ToJson(), results.Documents.First().ToJson());
        }