Пример #1
0
        public void ParallelMapWhile_FromDataRow()
        {
            var capitalizeRowPersister = new CapitalizeRowPersister <CustomerOrderHistory>();

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 참
                var histories = table.ParallelMapWhile <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 거짓 (모두 거부)
                var histories = table.ParallelMapWhile <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                histories.Count.Should().Be(0);
            }

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // Total 이 0보다 클 때까지만 변환
                var histories =
                    table.ParallelMapWhile <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsValue(0) > 0).
                    ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
        }
Пример #2
0
        public void MapFromDataRowWithFilter()
        {
            var capitalizeRowPersister = new CapitalizeRowPersister <CustomerOrderHistory>();

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 통과)
                var histories = table.MapIf <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                Assert.Greater(histories.Count, 0);
                histories.TrueForAll(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 거부)
                var histories = table.MapIf <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                Assert.AreEqual(0, histories.Count);
            }

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (Total 이 0보다 큰 레코드만)
                var histories =
                    table.MapIf <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsInt(0) > 0).ToList();

                Assert.Greater(histories.Count, 0);
                histories.TrueForAll(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
        }
Пример #3
0
        public void ParallelMapFromDataRowWithFilter()
        {
            // const string customerId = @"ANATR";

            var capitalizeRowPersister = new CapitalizeRowPersister <CustomerOrderHistory>();

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 통과)
                var histories = table.MapAsParallel <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 거부)
                var histories = table.MapAsParallel <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                histories.Count.Should().Be(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (Total 이 0보다 큰 레코드만)
                var histories =
                    table.MapAsParallel <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsValue <int>(0) > 0).
                    ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
        }
Пример #4
0
        public void MapWhile_From_DataRow()
        {
            var capitalizeRowPersister = new CapitalizeRowPersister <CustomerOrderHistory>();

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 참
                var histories = table.MapWhile <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 거짓 (모두 거부)
                var histories = table.MapWhile <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                histories.Count.Should().Be(0);
            }

            using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                //  Total 이 0보다 클 때까지만 변환
                var histories =
                    table.MapWhile <CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsInt(0) > 0).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
        }
Пример #5
0
        public void MapFromDataTableByPersister(int firstResult, int maxResults)
        {
            IRowPersister <CustomerOrderHistory> rowPersister = new CapitalizeRowPersister <CustomerOrderHistory>();

            using (
                var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist2", firstResult, maxResults,
                                                                               CustomerTestParameter)) {
                var histories = table.Map(rowPersister).ToList();

                if (maxResults > 0)
                {
                    Assert.GreaterOrEqual(maxResults, histories.Count);
                }
                else
                {
                    Assert.Greater(histories.Count, 0);
                }
            }
        }
Пример #6
0
        public void ParallelMapFromDataTableByPersister(int firstResult, int maxResults)
        {
            IRowPersister <CustomerOrderHistory> rowPersister = new CapitalizeRowPersister <CustomerOrderHistory>();

            using (
                var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist2", firstResult, maxResults,
                                                                               CustomerTestParameter)) {
                var histories = table.MapAsParallel(rowPersister).ToList();

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

                histories.All(history => history.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(history => history.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
        }
Пример #7
0
        public void ParallelMapWhile_FromDataRow() {
            var capitalizeRowPersister = new CapitalizeRowPersister<CustomerOrderHistory>();

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 참
                var histories = table.ParallelMapWhile<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 거짓 (모두 거부)
                var histories = table.ParallelMapWhile<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                histories.Count.Should().Be(0);
            }

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // Total 이 0보다 클 때까지만 변환
                var histories =
                    table.ParallelMapWhile<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsValue(0) > 0).
                        ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
        }
Пример #8
0
        public void ParallelMapFromDataRowWithFilter() {
            // const string customerId = @"ANATR";

            var capitalizeRowPersister = new CapitalizeRowPersister<CustomerOrderHistory>();

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 통과)
                var histories = table.MapAsParallel<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 거부)
                var histories = table.MapAsParallel<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                histories.Count.Should().Be(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (Total 이 0보다 큰 레코드만)
                var histories =
                    table.MapAsParallel<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsValue<int>(0) > 0).
                        ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(h => h.Total.HasValue && h.Total.Value > 0).Should().Be.True();
            }
        }
Пример #9
0
        public void ParallelMapFromDataTableByPersister(int firstResult, int maxResults) {
            IRowPersister<CustomerOrderHistory> rowPersister = new CapitalizeRowPersister<CustomerOrderHistory>();

            using(
                var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist2", firstResult, maxResults,
                                                                               CustomerTestParameter)) {
                var histories = table.MapAsParallel(rowPersister).ToList();

                if(maxResults > 0)
                    Assert.GreaterOrEqual(maxResults, histories.Count);
                else
                    Assert.Greater(histories.Count, 0);

                histories.All(history => history.ProductName.IsNotWhiteSpace()).Should().Be.True();
                histories.All(history => history.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
        }
Пример #10
0
        public void MapWhile_From_DataRow() {
            var capitalizeRowPersister = new CapitalizeRowPersister<CustomerOrderHistory>();

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 참
                var histories = table.MapWhile<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 계속 조건이 항상 거짓 (모두 거부)
                var histories = table.MapWhile<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                histories.Count.Should().Be(0);
            }

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                //  Total 이 0보다 클 때까지만 변환
                var histories =
                    table.MapWhile<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsInt(0) > 0).ToList();

                histories.Count.Should().Be.GreaterThan(0);
                histories.All(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
        }
Пример #11
0
        public void MapFromDataRowWithFilter() {
            var capitalizeRowPersister = new CapitalizeRowPersister<CustomerOrderHistory>();

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 통과)
                var histories = table.MapIf<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => true).ToList();

                Assert.Greater(histories.Count, 0);
                histories.TrueForAll(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (모두 거부)
                var histories = table.MapIf<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => false).ToList();

                Assert.AreEqual(0, histories.Count);
            }

            using(var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", CustomerTestParameter)) {
                // 필터링된 데이타 (Total 이 0보다 큰 레코드만)
                var histories =
                    table.MapIf<CustomerOrderHistory>(capitalizeRowPersister.Persist, row => row["Total"].AsInt(0) > 0).ToList();

                Assert.Greater(histories.Count, 0);
                histories.TrueForAll(h => h.Total.GetValueOrDefault() > 0).Should().Be.True();
            }
        }
Пример #12
0
        public void MapFromDataTableByPersister(int firstResult, int maxResults) {
            IRowPersister<CustomerOrderHistory> rowPersister = new CapitalizeRowPersister<CustomerOrderHistory>();

            using(
                var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist2", firstResult, maxResults,
                                                                               CustomerTestParameter)) {
                var histories = table.Map(rowPersister).ToList();

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