public async Task GetPromotionById_ReturnPromotion() { //arrange var promo = new Promotion { promotionId = 1, vendorId = 2, startDate = "01/16/1984", endDate = "02/16/1984", description = "promotion description!" }; //act _promoQueryMock.Setup(x => x.GetPromotion(1)) .Returns(Task.Factory.StartNew(() => promo)); var task = await _promoController.Get(1); // assert Assert.IsType <OkObjectResult>(task); var result = task as OkObjectResult; var returnedPromotion = result.Value as Promotion; Assert.Equal(returnedPromotion.promotionId, promo.promotionId); Assert.Equal(returnedPromotion.vendorId, promo.vendorId); Assert.Equal(returnedPromotion.startDate, promo.startDate); Assert.Equal(returnedPromotion.endDate, promo.endDate); Assert.Equal(returnedPromotion.description, promo.description); }
private void loadCbxDetail(int promotionId) { var promotion = promotionController.Get(promotionId); List <PromotionDto> list = new List <PromotionDto>(); if (promotion.Status == -1) { list.Add(promotion); } else { var list1 = promotionController.Gets(null, null, null, 0).ToList(); var list2 = promotionController.Gets(null, null, null, 1).ToList(); list.AddRange(list1); list.AddRange(list2); } cbxPromotion.DataSource = list; cbxPromotion.DisplayMember = "Title"; }
public void ItemsCanBeLookedUp() { var controller = new PromotionController(b); var theshowing = new Promotion { Expiration = DateTime.Now, PromotionCode = "", PromoType = Promotion.PromotionType.FlatRate, PromotionName = "5 off", PromoValue = 5 }; var showing = controller.Add(theshowing); var retrieved = controller.Get(showing); //retrieved.ShouldEqual(theshowing); // TODO: Need object comparison sans Id }
public PromotionsModule(OrmLiteConnectionFactory db) : base("/promotions") { const string obj = "Promotion"; // Would like to totally DRY this class out, but things get a little clunky // without careful planning. Not worthwhile for such a small project. Get["/"] = _ => { var controller = new PromotionController(db); return(View[obj + "List", controller.ListAll()]); }; Get["/{id}"] = req => { var controller = new PromotionController(db); var item = controller.Get(req.id); if (item == null) { return(404); } return(View[obj + "Detail", item]); }; Get["/create"] = _ => { return(View["New" + obj]); }; Post["/create"] = _ => { var item = this.Bind <Promotion>(); LogTo.Debug("Adding promotion: {0}", item); var controller = new PromotionController(db); var newId = controller.Add(item); return(Response.AsRedirect(ModulePath + "/" + newId)); }; Post["/update/{id}"] = _ => { return(500); }; }
public PromotionsModule(OrmLiteConnectionFactory db) : base("/promotions") { const string obj = "Promotion"; // Would like to totally DRY this class out, but things get a little clunky // without careful planning. Not worthwhile for such a small project. Get["/"] = _ => { var controller = new PromotionController(db); return View[obj + "List", controller.ListAll()]; }; Get["/{id}"] = req => { var controller = new PromotionController(db); var item = controller.Get(req.id); if (item == null) return 404; return View[obj + "Detail", item]; }; Get["/create"] = _ => { return View["New" + obj]; }; Post["/create"] = _ => { var item = this.Bind<Promotion>(); LogTo.Debug("Adding promotion: {0}", item); var controller = new PromotionController(db); var newId = controller.Add(item); return Response.AsRedirect(ModulePath + "/" + newId); }; Post["/update/{id}"] = _ => { return 500; }; }