public void Checkout_IdempotencyTest() { // Basket xml file for basict test string fullBasketFilePath = @"Data\Basket2.xml"; // Inject the catalog with the desired data model CatalogModel catalogModel = new Models.CatalogModel(new XmlDataModel(Utils.SafeGetConfigString("XmlCatalogFilePath", String.Empty))); // Main object Basket will handle the rest composed injected the file path to the basket and the desired catalog Basket basket = new Basket(fullBasketFilePath, catalogModel); // First call to Checkout, store the total basket.Checkout(); decimal firstCallTotal = basket.LineItems.Sum(m => m.Total); // Second call to Checkout, store the total basket.Checkout(); decimal secondCallTotal = basket.LineItems.Sum(m => m.Total); // We should have equal totals for the two runs without any changes Assert.AreEqual(firstCallTotal, secondCallTotal); }
public static void ShowKitchenDishGroups() { var _model = new Models.CatalogModel <DishKitchenGroup>( new Models.EditCatalogDataFuncs <DishKitchenGroup>() { AddItemFunc = DBProvider.Client.CreateDishKitchenGroup, EditItemFunc = DBProvider.Client.UpdateDishKitchenGroup, CancelAddItemFunc = DBProvider.Client.DeleteDishKitchenGroup, AllDataList = DataExtension.DataCatalogsSingleton.Instance.DishKitchenGroup } ); var vm = new Models.CatalogViewModel <DishKitchenGroup>(_model); vm.CanDeleteItem = false; ShowCatItem(vm, "Справочник кухонных групп"); }
public static void ShowContactPersons() { var _model = new Models.CatalogModel <ContactPerson>( new Models.EditCatalogDataFuncs <ContactPerson>() { AddItemFunc = DBProvider.Client.CreateContactPerson, EditItemFunc = DBProvider.Client.UpdateContactPerson, CancelAddItemFunc = DBProvider.Client.DeleteContactPerson, AllDataList = DataExtension.DataCatalogsSingleton.Instance.ContactPerson } ); var vm = new Models.CatalogViewModel <ContactPerson>(_model); vm.CanDeleteItem = false; ShowCatItem(vm, "Справочник стюардесс"); }
public static void ShowPaymentGroupsCatalog() { var _model = new Models.CatalogModel <PaymentGroup>( new Models.EditCatalogDataFuncs <PaymentGroup>() { AddItemFunc = DBProvider.Client.CreatePaymentGroup, EditItemFunc = DBProvider.Client.UpdatePaymentGroup, CancelAddItemFunc = DBProvider.Client.DeletePaymentGroup, AllDataList = DataExtension.DataCatalogsSingleton.Instance.PaymentGroups } ); var vm = new Models.CatalogViewModel <PaymentGroup>(_model); vm.CanDeleteItem = false; ShowCatItem(vm, "Справочник груп оплат"); }
public static void ShowMarketingChanelsCatalog() { var _model = new Models.CatalogModel <MarketingChannel>( new Models.EditCatalogDataFuncs <MarketingChannel>() { AddItemFunc = DBProvider.Client.CreateMarketingChannel, EditItemFunc = DBProvider.Client.UpdateMarketingChannel, CancelAddItemFunc = DBProvider.Client.DeleteMarketingChannel, AllDataList = DataExtension.DataCatalogsSingleton.Instance.MarketingChannels } ); var vm = new Models.CatalogViewModel <MarketingChannel>(_model); vm.CanDeleteItem = false; ShowCatItem(vm, "Справочник каналов маркетинга"); }
public static void ShowDriverCatalog() { var _model = new Models.CatalogModel <Driver>( new Models.EditCatalogDataFuncs <Driver>() { AddItemFunc = DBProvider.Client.CreateDriver, EditItemFunc = DBProvider.Client.UpdateDriver, CancelAddItemFunc = DBProvider.Client.DeleteDriver, AllDataList = DataExtension.DataCatalogsSingleton.Instance.Drivers } ); var vm = new Models.CatalogViewModel <Driver>(_model); vm.CanDeleteItem = false; ShowCatItem(vm, "Справочник водителей"); }
public static void ShowAirCompanyCatalog() { var _model = new Models.CatalogModel <AirCompany>( new Models.EditCatalogDataFuncs <AirCompany>() { AddItemFunc = DBProvider.Client.CreateAirCompany, EditItemFunc = DBProvider.Client.UpdateAirCompany, CancelAddItemFunc = DBProvider.Client.DeleteAirCompany, AllDataList = DataExtension.DataCatalogsSingleton.Instance.AllAirCompanies } ); var vm = new Models.CatalogViewModel <AirCompany>(_model); vm.CanDeleteItem = false; ShowCatItem(vm, "Справочник авиакомпаний"); }
public void Checkout_BasicTest() { // Basket xml file for basict test string fullBasketFilePath = @"Data\Basket.xml"; // Inject the catalog with the desired data model CatalogModel catalogModel = new Models.CatalogModel(new XmlDataModel(Utils.SafeGetConfigString("XmlCatalogFilePath", String.Empty))); // Main object Basket will handle the rest composed injected the file path to the basket and the desired catalog Basket basket = new Basket(fullBasketFilePath, catalogModel); // Checkout is the main method on basket that processes all the basket items and applies all relevant discounts per the catalog definitions storing all in basket for later access. basket.Checkout(); // We should be getting lots of line items Assert.AreNotEqual(basket.LineItems.Count, 0); }
public static void ShowDeliveryPlaceCatalog() { var _model = new Models.CatalogModel <DeliveryPlace>( new Models.EditCatalogDataFuncs <DeliveryPlace>() { AddItemFunc = DBProvider.Client.CreateDeliveryPlace, EditItemFunc = DBProvider.Client.UpdateDeliveryPlace, CancelAddItemFunc = DBProvider.Client.DeleteDeliveryPlace, //GetId = (Air) => { return Air.Id; }, AllDataList = DataExtension.DataCatalogsSingleton.Instance.DeliveryPlaces }); var ItemsCatalog = new UI.CtrlCatalogView2(); ItemsCatalog.DataContext = new Models.CatalogViewModel <DeliveryPlace>(_model) { Header = "Справочник мест доставки" }; MainClass.ShowUC(ItemsCatalog); }
public void Checkout_AddonDiscountCountTest() { // Basket xml file for basict test string fullBasketFilePath = @"Data\Basket2.xml"; // Inject the catalog with the desired data model CatalogModel catalogModel = new Models.CatalogModel(new XmlDataModel(Utils.SafeGetConfigString("XmlCatalogFilePath", String.Empty))); // Main object Basket will handle the rest composed injected the file path to the basket and the desired catalog Basket basket = new Basket(fullBasketFilePath, catalogModel); // Checkout is the main method on basket that processes all the basket items and applies all relevant discounts per the catalog definitions storing all in basket for later access. basket.Checkout(); int addonDiscountLineItemsCount = basket.LineItems.Where(m => m.LineItemType == Entities.DiscountTypes.groupDiscount).Count(); // We should have ONE groupDiscount line item Assert.AreEqual(addonDiscountLineItemsCount, 1); }
private static void ShowItemsCatalog(string name, FullyObservableCollection <Dish> data) { var GetDataFuncs = new Models.EditCatalogDataFuncs <Dish>() { AddItemFunc = DBProvider.Client.CreateDish, EditItemFunc = DBProvider.Client.UpdateDish, CancelAddItemFunc = DBProvider.Client.DeleteDish, AllDataList = data }; var _model = new Models.CatalogModel <Dish>(GetDataFuncs); var ItemsCatalog = new UI.CtrlCatalogView2(); var ItemsCatalogVm = new Models.CatalogViewModel <Dish>(_model) { Header = name }; ItemsCatalogVm.CanDeleteItem = false; ItemsCatalog.DataContext = ItemsCatalogVm; MainClass.ShowUC(ItemsCatalog); }