public void Test_QryAccount_POCO_Context_and_Reader() // assumes that 10 records exist with extra info data { QryAccountContext context = new QryAccountContext(); Options opt = OdbcOptions.GetOptions("DSN=LOCALDELTATEST"); context.init(opt); for (int i = 0; i < 10; i++) { QryAccount tmp = context._Records.Skip(i).FirstOrDefault(); Assert.IsFalse(0 == tmp.AUnique); Assert.AreNotEqual(string.Empty, tmp.BankInfo.Trim()); } }
public void Test_facade_to_wrap_InvAss_Wholesaler_pairs_to_a_data_load_format() { // C: create a facade to go from InvAss, wholesaler pairs to a data load format // Data load fields (ICommonFields + InvUnique, Cat, and PartNumber): InvUnique, Cat, PartNumber // ICommonFields: SupplierName, SupplierPartNumber, SupplierCode WholesaleCost, PriceSchedule1_MSRP // , PriceSchedule2_MinPrice const int commonId = 3; const string matching_supplier_code = "matching_code"; const string supp_part_num = "SamplePartNum"; const string supp_name = "Some Supplier Name"; S5Inventory InvRaw = Get_Sample_S5Inventory_for_one_Inventory_Item(); IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled(); var First = InvAss.First(); First.Inv.Supplier = commonId; First.Inv.SuppPart = supp_part_num; QryAccount acct = new QryAccount(); acct.AName = supp_name; acct.AUnique = commonId; acct.BankInfo = matching_supplier_code; (IS5InvAssembled InvAss, QryAccount ExtraInfo)pair = new ValueTuple <IS5InvAssembled, QryAccount>(First, acct); IDataLoadFormat DataLoadRecord; AdaptToDataLoadFormat adapter = new AdaptToDataLoadFormat(); adapter.Init(pair); DataLoadRecord = adapter; Assert.AreEqual(matching_supplier_code, adapter.SupplierCode); Assert.AreEqual("211545", adapter.PartNumber); Assert.AreEqual(12018, adapter.InvUnique); //confirm that the prices below are correct by geting real data to sample Assert.AreEqual((decimal)59.99, adapter.PriceSchedule1_MSRP); Assert.AreEqual((decimal)69.99, adapter.PriceSchedule2_MinPrice); Assert.AreEqual(supp_name, adapter.SupplierName); Assert.AreEqual(supp_part_num, adapter.SupplierPartNumber); Assert.AreEqual(29, adapter.WholesaleCost); }
public void Test_creating_Tuples_as_a_way_of_attaching_wholesaler_to_Assembled_Inventory() { // B: Attach BankInfo / wholesaler to Assembled Inventory to make InvAss, wholesaler pairs // - UpdateProcess<TCommon, TKey> usage via example here: Test_GetUpdatesByCommonFields_OneOfTwoRecordsChanges() // UpdateProcess isn't what we use here as the pattern is different. // Use the Generic Join functionality that creates tuples instead const int commonId = 3; const string matching_supplier_code = "matching_code"; S5Inventory InvRaw = Get_Sample_S5Inventory_for_one_Inventory_Item(); IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled(); var First = InvAss.First(); First.Inv.Supplier = commonId; Assert.AreEqual(commonId, InvAss.First().Inv.Supplier); // confirm source has change QryAccount acct = new QryAccount(); acct.AName = "Test Matching Supplier"; acct.AUnique = commonId; // save as above acct.BankInfo = matching_supplier_code; List <QryAccount> accts = new List <QryAccount>(); accts.Add(acct); Func <QryAccount, int> QryAccount_Index = (record) => { return(record.AUnique); }; IEnumerable <Tuple <IS5InvAssembled, QryAccount> > result = GenericJoins <IS5InvAssembled, QryAccount, int> .InnerJoin(InvAss, accts, IS5InvAssembled_Indexes.SupplierUnique_Key, QryAccount_Index); Assert.AreEqual(1, result.Count()); Assert.AreEqual(commonId, result.First().Item1.Inv.Supplier); Assert.AreEqual(matching_supplier_code, result.First().Item2.BankInfo); }
public void IntegrationTest_Get_XRef_from_Supplier_Account_For_Aunique_BankInfo_Pairs() // convert to unit test { // A: Get XRef from Account for AUnique,BankInfo pairs QryAccountContext context = new QryAccountContext(); Options opt = OdbcOptions.GetOptions("DSN=LOCALDELTATEST"); context.init(opt); Func <QryAccount, QryAccount> clean = (acct) => { acct.AName = acct.AName.TrimEnd(); acct.BankInfo = acct.BankInfo.TrimEnd(); return(acct); }; IEnumerable <QryAccount> records = context._Records.Select(r => clean(r)); for (int i = 0; i < 10; i++) { QryAccount tmp = context._Records.Skip(i).FirstOrDefault(); Assert.IsFalse(0 == tmp.AUnique); Assert.AreNotEqual(string.Empty, tmp.BankInfo.TrimEnd()); } }
public AdaptToDataLoadFormat() { _InvAss = new S5InvAssembled(); _SuppInfo = new QryAccount(); }