public PromotionServiceTests() { _appContext = new FakeAppContext(); SetupContent(); SetupPricing(); SetupMarkets(); SetupReferenceConverter(); SetupPromotionEngine(); _lineItemcalculatorMock = new Mock <ILineItemCalculator>(); SetupDiscountedPrice(); _subject = new PromotionService( _pricingServiceMock.Object, _marketServiceMock.Object, _contentLoaderMock.Object, _referenceConverterMock.Object, _lineItemcalculatorMock.Object, _promotionEngineMock.Object ); }
public void QueueDeclare_WithIModel_InvokesQueueDeclareFromModel() { modelMocker.Setup(o => o.QueueDeclare( It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <IDictionary <string, object> >())) .Returns(queueDeclareOk); PromotionService sut = GetSut(); sut.QueueDeclare(modelMocker.Object); modelMocker.Verify(o => o.QueueDeclare( It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <IDictionary <string, object> >()), Times.Once); }
/// <summary> /// For now service is created each time, there are other better ways /// to do it like using DI or a Factory pattern etc. /// </summary> /// <returns></returns> private IPromotionService GetService() { var service = default(IPromotionService); switch (this.Type) { case PromotionType.Single: service = new PromotionService(); break; case PromotionType.Combo: service = new ComboPromotionService(); break; case PromotionType.Percent: service = new PercentPromotionService(); break; } return(service); }
private bool SetStarState(int promotionId, bool newState) { //Create the service var userId = Guid.Parse(User.Identity.GetUserId()); var service = new PromotionService(userId); // Get the promotion var detail = service.GetPromotionById(promotionId); // Create the PromotionEdit model instance wih the new star state var updatedPromotion = new PromotionEdit { PromotionId = detail.PromotionId, PromotionName = detail.PromotionName, IsStarred = newState, DateFounded = detail.DateFounded, Website = detail.Website }; //Return a value indicating whether the update succeeded return(service.UpdatePromotion(updatedPromotion)); }
public void TestApplyingOnePromotionToBasketWithTwoDifferentItems() { List <PromotionModel> promotions = new List <PromotionModel> { _appleDiscount }; BasketItemModel appleBasketItem = new BasketItemModel(_apple); BasketItemModel orangeBasketItem = new BasketItemModel(_orange); BasketModel basket = new BasketModel(); basket.AddOrUpdateBasket(appleBasketItem); basket.AddOrUpdateBasket(orangeBasketItem); IPromotionService promotionService = new PromotionService(); promotionService.ApplyPromotionsToBasket(basket, promotions); Assert.AreEqual(2, basket.Basket.Count); Assert.AreEqual(3, basket.Total); Assert.IsTrue(basket.Basket[0].Discount != null); Assert.AreEqual("Apple", basket.Basket[0].ItemName); Assert.IsTrue(basket.Basket[1].Discount == null); Assert.AreEqual("Orange", basket.Basket[1].ItemName); Assert.AreEqual(0.5M, basket.Basket[0].Discount.TotalDiscountAmount); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="businessId">The AdWords Express business id.</param> /// <param name="promotionId">The promotion id.</param> public void Run(AdWordsUser user, long businessId, long promotionId) { // Get the ExpressBusinessService. ExpressBusinessService businessService = (ExpressBusinessService) user.GetService(AdWordsService.v201506.ExpressBusinessService); // Get the PromotionService PromotionService promotionService = (PromotionService) user.GetService(AdWordsService.v201506.PromotionService); // Set the business ID to the service. promotionService.RequestHeader.expressBusinessId = businessId; // Update the budget for the promotion Promotion promotion = new Promotion(); promotion.id = promotionId; Money newBudget = new Money(); newBudget.microAmount = 2000000; promotion.budget = newBudget; PromotionOperation operation = new PromotionOperation(); operation.@operator = Operator.SET; operation.operand = promotion; try { Promotion[] updatedPromotions = promotionService.mutate( new PromotionOperation[] { operation }); Console.WriteLine("Promotion ID {0} for business ID {1} now has budget micro " + "amount {2}.", promotionId, businessId, updatedPromotions[0].budget.microAmount); } catch (Exception ex) { throw new System.ApplicationException("Failed to update promotions.", ex); } }
public static IPromotion CrearConexionServicio3(Models.ConnectionType type, string connectionString) { IPromotion nuevoMotor = null; switch (type) { case Models.ConnectionType.NONE: break; case Models.ConnectionType.MSSQL: SqlConexion sql = SqlConexion.Conectar(connectionString); nuevoMotor = PromotionService.CrearInstanciaSQL(sql); break; case Models.ConnectionType.MYSQL: break; default: break; } return(nuevoMotor); }
public JsonResult Promotions() { var items = new PromotionService().GetPromotions(); return(Json(items, JsonRequestBehavior.AllowGet)); }
public PromotionController(DiscordSocketClient client, PromotionService promotionService) : base(client) { _promotionService = promotionService; }
public PromotionController(PromotionService promotionService) { _promotionService = promotionService; }
public void Constructor_ShouldThrowArgumentNullException_WhenDataParameterIsNull() { // Arrange & Act & Assert var promotionService = new PromotionService(null); }
public PromotionServiceTests() { promotionService = new PromotionService(); }
private PromotionService GetSut() { PromotionService sut = consoleServiceMocker.Object; return(sut); }
protected List <BundleItem> GetBundle() { //get the bundles from the PromoService return(PromotionService.GetBundleByProduct(product.ProductID)); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="businessId">The AdWords Express business id.</param> public void Run(AdWordsUser user, long businessId) { // Get the ExpressBusinessService. ExpressBusinessService businessService = (ExpressBusinessService) user.GetService(AdWordsService.v201409.ExpressBusinessService); // Get the PromotionService PromotionService promotionService = (PromotionService) user.GetService(AdWordsService.v201409.PromotionService); // Get the business for the businessId. We will need its geo point to // create a Proximity criterion for the new Promotion. Selector businessSelector = new Selector(); Predicate predicate = new Predicate(); predicate.field = "Id"; predicate.@operator = PredicateOperator.EQUALS; predicate.values = new string[] { businessId.ToString() }; businessSelector.predicates = new Predicate[] { predicate }; businessSelector.fields = new string[] { "Id", "GeoPoint" }; ExpressBusinessPage businessPage = businessService.get(businessSelector); if (businessPage == null || businessPage.entries == null || businessPage.entries.Length == 0) { Console.WriteLine("No business was found."); return; } // Set the business ID to the service. promotionService.RequestHeader.expressBusinessId = businessId; // First promotion Promotion marsTourPromotion = new Promotion(); Money budget = new Money(); budget.microAmount = 1000000L; marsTourPromotion.name = "Mars Tour Promotion " + ExampleUtilities.GetShortRandomString(); marsTourPromotion.status = PromotionStatus.PAUSED; marsTourPromotion.destinationUrl = "http://www.example.com"; marsTourPromotion.budget = budget; marsTourPromotion.callTrackingEnabled = true; // Criteria // Criterion - Travel Agency product service ProductService productService = new ProductService(); productService.text = "Travel Agency"; // Criterion - English language // The ID can be found in the documentation: // https://developers.google.com/adwords/api/docs/appendix/languagecodes Language language = new Language(); language.id = 1000L; // Criterion - Within 15 miles Proximity proximity = new Proximity(); proximity.geoPoint = businessPage.entries[0].geoPoint; proximity.radiusDistanceUnits = ProximityDistanceUnits.MILES; proximity.radiusInUnits = 15; marsTourPromotion.criteria = new Criterion[] { productService, language, proximity }; // Creative Creative creative = new Creative(); creative.headline = "Standard Mars Trip"; creative.line1 = "Fly coach to Mars"; creative.line2 = "Free in-flight pretzels"; marsTourPromotion.creatives = new Creative[] { creative }; PromotionOperation operation = new PromotionOperation(); operation.@operator = Operator.ADD; operation.operand = marsTourPromotion; try { Promotion[] addedPromotions = promotionService.mutate( new PromotionOperation[] { operation }); Console.WriteLine("Added promotion ID {0} with name {1} to business ID {2}.", addedPromotions[0].id, addedPromotions[0].name, businessId); } catch (Exception ex) { throw new System.ApplicationException("Failed to add promotions.", ex); } }
public BranchViewModel(INavigationService navigationService) { _eventService = new EventService(); _promotionService = new PromotionService(); _navigationService = navigationService; }
public IEnumerable <Promotion> GetPromotion(Expression <Func <Promotion, bool> > expr) { return(PromotionService.GetActive(expr)); }
public IEnumerable <Promotion> GetPromotion() { return(PromotionService.GetActive()); }
public DiscountPolicyController(PromotionService service) { _promotionService = service; }
public PromotionServiceTest() { _sut = new PromotionService(); }
public PromotionController(PromotionService promServ) { this.promServ = promServ; }
public JsonResult PromotionsByPaging(DataTablesPaging request) { var view = new PromotionService().GetPromotionsByPaging(request); return(Json(view, JsonRequestBehavior.AllowGet)); }
public PromotionModule(PromotionService service) { _service = service; }
public Promotion Create(Promotion p) { PromotionService.Create(p); return(p); }
public Promotion GetPromotion(int pDetailId) { return(PromotionService.GetActive(p => p.PromotionID == pDetailId).FirstOrDefault()); }
protected void btnDelete_Click(object sender, EventArgs e) { PromotionService.DeleteBundle(int.Parse(lblID.Text)); Response.Redirect(Request.Url.PathAndQuery, false); }
public PromotionCardDetailViewModel() { promotionService = new PromotionService(); }
public Promotion GetPromotion(string pCode) { return(PromotionService.GetActive(p => p.PromotionCode == pCode).FirstOrDefault()); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="businessId">The AdWords Express business id.</param> public void Run(AdWordsUser user, long businessId) { // Get the PromotionService PromotionService promotionService = (PromotionService) user.GetService(AdWordsService.v201605.PromotionService); // Set the business ID to the service. promotionService.RequestHeader.expressBusinessId = businessId; // First promotion Promotion marsTourPromotion = new Promotion(); Money budget = new Money(); budget.microAmount = 1000000L; marsTourPromotion.name = "Mars Tour Promotion " + ExampleUtilities.GetShortRandomString(); marsTourPromotion.status = PromotionStatus.PAUSED; marsTourPromotion.destinationUrl = "http://www.example.com"; marsTourPromotion.budget = budget; marsTourPromotion.callTrackingEnabled = true; // Criteria // Criterion - Travel Agency product service ProductService productService = new ProductService(); productService.text = "Travel Agency"; // Criterion - English language // The ID can be found in the documentation: // https://developers.google.com/adwords/api/docs/appendix/languagecodes Language language = new Language(); language.id = 1000L; // Criterion - State of California Location location = new Location(); location.id = 21137L; marsTourPromotion.criteria = new Criterion[] { productService, language, location }; // Creative Creative creative = new Creative(); creative.headline = "Standard Mars Trip"; creative.line1 = "Fly coach to Mars"; creative.line2 = "Free in-flight pretzels"; marsTourPromotion.creatives = new Creative[] { creative }; PromotionOperation operation = new PromotionOperation(); operation.@operator = Operator.ADD; operation.operand = marsTourPromotion; try { Promotion[] addedPromotions = promotionService.mutate( new PromotionOperation[] { operation }); Console.WriteLine("Added promotion ID {0} with name {1} to business ID {2}.", addedPromotions[0].id, addedPromotions[0].name, businessId); } catch (Exception e) { throw new System.ApplicationException("Failed to add promotions.", e); } }
public Promotion Update(Promotion p) { PromotionService.Update(p); return(p); }