Esempio n. 1
0
        public void ParallelMapFromDataReader_Employee()
        {
            using (var reader = NorthwindAdoRepository.ExecuteReaderAsync(SQL_EMPLOYEE_SELECT).Result) {
                var employees = reader.MapAsParallel <Employee>(() => new Employee(), e => e.Photo);
                reader.Dispose();

                Assert.Greater(employees.Count, 0);

                employees.All(emp => emp.EmployeeID > 0).Should().Be.True();
                employees.All(emp => emp.Address.IsNotWhiteSpace()).Should().Be.True();
                employees.All(emp => emp.Photo == null).Should().Be.True();
            }
        }
Esempio n. 2
0
        public void ParallelMapFromDataReader_OrderDetails()
        {
            using (var reader = NorthwindAdoRepository.ExecuteReaderAsync(SQL_ORDER_DETAIL_SELECT).Result) {
                var orderDetails = reader.MapAsParallel <OrderDetail>(() => new OrderDetail());
                reader.Dispose();

                Assert.Greater(orderDetails.Count, 0);

                orderDetails.All(od => od.OrderID > 0).Should().Be.True();
                orderDetails.All(od => od.ProductID > 0).Should().Be.True();
                orderDetails.All(od => od.Quantity > 0).Should().Be.True();
                orderDetails.All(od => od.Discount >= 0.0f).Should().Be.True();
            }
        }
Esempio n. 3
0
        public void ParallelMapFromDataReader_Employee_Paginated(int firstResult, int maxResults)
        {
            using (var reader = NorthwindAdoRepository.ExecuteReaderAsync(SQL_EMPLOYEE_SELECT).Result) {
                var employees = reader.MapAsParallel <Employee>(() => new Employee(), firstResult, maxResults, e => e.Photo);

                reader.Dispose();

                if (maxResults > 0)
                {
                    Assert.GreaterOrEqual(maxResults, employees.Count);
                }
                else
                {
                    Assert.Greater(employees.Count, maxResults);
                }

                employees.All(emp => emp.EmployeeID > 0).Should().Be.True();
                employees.All(emp => emp.Address.IsNotWhiteSpace()).Should().Be.True();
                employees.All(emp => emp.Photo == null).Should().Be.True();
            }
        }