public void ParallelMapFromDataTableByPaging(string customerId, int firstResult, int maxResults) { using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist2", firstResult, maxResults, CustomerTestParameter)) { Assert.IsFalse(table.HasErrors); Assert.Greater(table.Rows.Count, 1); var histories = table .MapAsParallel <CustomerOrderHistory>(ActivatorTool.CreateInstance <CustomerOrderHistory>, CapitalizeMapper) .ToList(); if (IsDebugEnabled) { log.Debug(histories.CollectionToString()); } 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(); } }
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(); } }
public void ParallelMapFromDataTableByMapFunc(int firstResult, int maxResults) { Func <DataRow, CustomerOrderHistory> @mapper = row => new CustomerOrderHistory { ProductName = row["ProductName"].AsText(), Total = row["Total"].AsIntNullable() }; using ( var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { var histories = table.MapAsParallel(@mapper).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(); } }
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(); } }
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(); } }
public void MapFromDataTableByMapFunc(int firstResult, int maxResults) { Func <DataRow, CustomerOrderHistory> @mapper = row => { var history = new CustomerOrderHistory { ProductName = row["ProductName"].ToString(), Total = row["Total"].AsIntNullable() }; return(history); }; using ( var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { var histories = table.Map(@mapper).ToList(); if (maxResults > 0) { Assert.GreaterOrEqual(maxResults, histories.Count); } else { Assert.Greater(histories.Count, 0); } } }
public void MapFromDataTableByPaging(string customerId, int firstResult, int maxResults) { using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist2", firstResult, maxResults, CustomerTestParameter)) { Assert.IsFalse(table.HasErrors); Assert.Greater(table.Rows.Count, 1); var histories = table.Map <CustomerOrderHistory>(CapitalizeMapper).ToList(); if (IsDebugEnabled) { log.Debug(histories.CollectionToString()); } if (maxResults > 0) { Assert.GreaterOrEqual(maxResults, histories.Count); } else { Assert.Greater(histories.Count, 0); } } }
public void ConvertAllFromDataTableByConverter(int firstResult, int maxResults) { Func <DataRow, CustomerOrderHistory> @mapFunc = row => new CustomerOrderHistory { ProductName = row["PRODUCTNAME"].AsText(), Total = row["TOTAL"].AsIntNullable() }; using (var dt = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { Assert.IsFalse(dt.HasErrors); Assert.Greater(dt.Rows.Count, 1); var orderHistories = AdoTool.Map(dt, @mapFunc); if (IsDebugEnabled) { log.Debug(orderHistories.CollectionToString()); } Assert.Greater(orderHistories.Count, 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(); } }
public void ExecuteDataTableByProcedure(int firstResult, int maxResults) { using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure(GetCustomerOrderHistorySql, firstResult, maxResults, CustomerTestParameter)) { Assert.IsFalse(table.HasErrors); Assert.Greater(table.Rows.Count, 0); Console.WriteLine("RowCount=[{0}]", table.Rows.Count); } }
public void ExecuteDataTableToInstance(int firstResult, int maxResults) { using (var table = NorthwindAdoRepository.ExecuteDataTableByProcedure(GetCustomerOrderHistorySql, firstResult, maxResults, CustomerTestParameter)) { Assert.IsFalse(table.HasErrors); Assert.Greater(table.Rows.Count, 1); var orderHistories = AdoTool.Map <CustomerOrderHistory>(table); Assert.Greater(orderHistories.Count, 1); } }
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); } } }
public void ConvertAllFromDataTable(int firstResult, int maxResults) { using (var dt = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { Assert.IsFalse(dt.HasErrors); Assert.Greater(dt.Rows.Count, 1); var orderHistories = AdoTool.Map <CustomerOrderHistory>(dt); if (IsDebugEnabled) { log.Debug("OrderHistories:" + orderHistories.CollectionToString()); } Assert.Greater(orderHistories.Count, 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(); } }
public void ParallelMapFromDataTableExcludeProperty(int firstResult, int maxResults) { // Total 속성의 값은 매핑하지 않는다. // using ( var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { var histories = table.MapAsParallel <CustomerOrderHistory>("Total").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) == 0).Should().Be.True(); } }
public void ParallelMapPersistenceFromDataTable(int firstResult, int maxResults) { // 단순히 TrimMapper 를 이용하여 Persistence를 생성합니다. // using ( var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { var histories = table.MapAsParallel <CustomerOrderHistory>().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(); } }
public void ConvertAllFromDataTableByNameMappingFuncs(int firstResult, int maxResults) { // CustOrderHist2 Procedure를 만들어야 한다. (Column 명을 대문자, '_'로 바꾼다. 즉 PRODUCT_NAME, TOTAL 로 column명만 바꾼다 using (var dt = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist2", firstResult, maxResults, CustomerTestParameter)) { Assert.IsFalse(dt.HasErrors); Assert.Greater(dt.Rows.Count, 1); var orderHistories = AdoTool.Map <CustomerOrderHistory>(dt, dt.Mapping(NameMappingUtil .CapitalizeMappingFunc('_', ' '))); if (IsDebugEnabled) { log.Debug(orderHistories.CollectionToString()); } Assert.Greater(orderHistories.Count, 0); } }
//[TestCase(0, 50)] //[TestCase(5, 200)] public void MapPersistenceFromDataTable(int firstResult, int maxResults) { // 단순히 TrimMapper 를 이용하여 Persistence를 생성합니다. // using ( var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { var histories = table.Map <CustomerOrderHistory>().ToList(); if (maxResults > 0) { Assert.GreaterOrEqual(maxResults, histories.Count); } else { Assert.Greater(histories.Count, 0); } histories.TrueForAll(h => h.Total.GetValueOrDefault(0) > 0); } using (var table = NorthwindAdoRepository.ExecuteDataTableBySqlString(SQL_CUSTOMER_SELECT, firstResult, maxResults)) { var customers = table.Map <Customer>().ToList(); if (maxResults > 0) { Assert.GreaterOrEqual(maxResults, customers.Count); } else { Assert.Greater(customers.Count, 0); } customers.All(c => c.CustomerID.IsNotWhiteSpace()).Should().Be.True(); customers.All(c => c.Address.IsNotWhiteSpace()).Should().Be.True(); } }
public void MapFromDataTableExcludeProperty(int firstResult, int maxResults) { // Total 속성의 값은 매핑하지 않는다. // using ( var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { var histories = table.Map <CustomerOrderHistory>(new[] { "Total" }).ToList(); if (maxResults > 0) { Assert.GreaterOrEqual(maxResults, histories.Count); } else { Assert.Greater(histories.Count, 0); } histories.All(x => x.Total == 0).Should().Be.True(); } using (var table = NorthwindAdoRepository.ExecuteDataTableBySqlString(SQL_CUSTOMER_SELECT, firstResult, maxResults)) { var customers = table.Map <Customer>(new string[0]); if (maxResults > 0) { Assert.GreaterOrEqual(maxResults, customers.Count); } else { Assert.Greater(customers.Count, 0); } customers.All(c => c.CustomerID.IsNotWhiteSpace()).Should().Be.True(); customers.All(c => c.Address.IsNotWhiteSpace()).Should().Be.True(); } }