示例#1
0
        public async Task AddCollectionAsync()
        {
            var employees = new List <Employee> {
                EmployeeGenerator.Generate(name: "  BLAKE  "),
                EmployeeGenerator.Generate(name: "\tBLAKE  ")
            };
            await _employeeRepository.AddAsync(employees);

            var result = await _employeeRepository.GetByIdsAsync(new Ids(employees.Select(e => e.Id)));

            Assert.Equal(2, result.Count);
            Assert.True(result.All(e => String.Equals(e.Name, "blake")));
        }
        public async Task CanGetByIds()
        {
            var employee = await _repository.AddAsync(EmployeeGenerator.Generate());

            Assert.NotNull(employee.Id);

            var result = await _repository.GetByIdAsync(employee.Id);

            Assert.NotNull(result);
            Assert.Equal(employee.Id, result.Id);

            var employee2 = await _repository.AddAsync(EmployeeGenerator.Generate());

            Assert.NotNull(employee2.Id);

            var results = await _repository.GetByIdsAsync(new [] { employee.Id, employee2.Id });

            Assert.NotNull(results);
            Assert.Equal(2, results.Total);
        }
        public async Task AddCollectionAsync()
        {
            var employee = EmployeeGenerator.Default;

            Assert.Equal(0, employee.Version);

            var employees = new List <Employee> {
                employee, EmployeeGenerator.Generate()
            };
            await _employeeRepository.AddAsync(employees);

            Assert.Equal(1, employee.Version);

            var result = await _employeeRepository.GetByIdsAsync(employees.Select(e => e.Id).ToList());

            Assert.Equal(2, result.Count);
            Assert.Equal(employees[0], result.First());
            Assert.Equal(employees[1], result.Last());
        }