public void CanCreateAPromotion() { Promotion p = new Promotion(); PromotionRepository r = PromotionRepository.InstantiateForMemory(new RequestContext()); Assert.IsTrue(r.Create(p), "Create should be true"); Assert.IsNotNull(p); Assert.IsTrue(p.Id > 0, "Promotion was not assigned an Id number"); }
public void Promotion_CanCreateAPromotion() { var app = CreateHccAppInMemory(); var p = new Promotion(); var r = new PromotionRepository(new HccRequestContext()); Assert.IsTrue(r.Create(p), "Create should be true"); Assert.IsNotNull(p); Assert.IsTrue(p.Id > 0, "Promotion was not assigned an Id number"); }
public void CanFindPromotionInRepository() { Promotion p = new Promotion(); p.Name = "FindMe"; PromotionRepository r = PromotionRepository.InstantiateForMemory(new RequestContext()); Assert.IsTrue(r.Create(p), "Create should be true"); Assert.IsNotNull(p); Assert.IsTrue(p.Id > 0, "Promotion was not assigned an Id number"); Promotion target = r.Find(p.Id); Assert.IsNotNull(target, "Found should not be null"); Assert.AreEqual(p.Id, target.Id, "Id didn't match"); Assert.AreEqual(p.StoreId, target.StoreId, "Store ID Didn't Match"); Assert.AreEqual(p.Name, target.Name, "Name didn't match"); }
public void Promotion_CanSaveQualificationsAndActionsInRepository() { var app = CreateHccAppInMemory(); var p = new Promotion { Mode = PromotionType.Sale, Name = "FindMe" }; p.AddQualification(new ProductBvin(new List <string> { "ABC123" })); p.AddQualification(new ProductType("TYPE0")); p.AddAction(new ProductPriceAdjustment(AmountTypes.Percent, 50)); var r = new PromotionRepository(new HccRequestContext()); Assert.IsTrue(r.Create(p), "Create should be true"); Assert.IsNotNull(p); Assert.IsTrue(p.Id > 0, "Promotion was not assigned an Id number"); var target = r.Find(p.Id); Assert.IsNotNull(target, "Found should not be null"); Assert.AreEqual(p.Id, target.Id, "Id didn't match"); Assert.AreEqual(p.StoreId, target.StoreId, "Store ID Didn't Match"); Assert.AreEqual(p.Name, target.Name, "Name didn't match"); Assert.AreEqual(p.Qualifications.Count, target.Qualifications.Count, "Qualification count didn't match"); for (var i = 0; i < p.Qualifications.Count; i++) { Assert.AreEqual(p.Qualifications[0].Id, target.Qualifications[0].Id, "Id of index " + i + " didn't match"); Assert.AreEqual(p.Qualifications[0].GetType(), target.Qualifications[0].GetType(), "Type of index " + i + " didn't match"); } Assert.AreEqual(p.Actions.Count, target.Actions.Count, "Action count didn't match"); for (var i = 0; i < p.Actions.Count; i++) { Assert.AreEqual(p.Actions[0].Id, target.Actions[0].Id, "Id of action index " + i + " didn't match"); Assert.AreEqual(p.Actions[0].GetType(), target.Actions[0].GetType(), "Type of action index " + i + " didn't match"); } }
public void Promotion_CanFindPromotionInRepository() { var app = CreateHccAppInMemory(); var p = new Promotion(); p.Name = "FindMe"; var r = new PromotionRepository(new HccRequestContext()); Assert.IsTrue(r.Create(p), "Create should be true"); Assert.IsNotNull(p); Assert.IsTrue(p.Id > 0, "Promotion was not assigned an Id number"); var target = r.Find(p.Id); Assert.IsNotNull(target, "Found should not be null"); Assert.AreEqual(p.Id, target.Id, "Id didn't match"); Assert.AreEqual(p.StoreId, target.StoreId, "Store ID Didn't Match"); Assert.AreEqual(p.Name, target.Name, "Name didn't match"); }
public void CanUpdateNameOfPromotion() { Promotion p = new Promotion(); p.Name = "Old"; PromotionRepository r = PromotionRepository.InstantiateForMemory(new RequestContext()); r.Create(p); string updatedName = "New"; p.Name = updatedName; Assert.IsTrue(r.Update(p), "Update should be true"); Promotion target = r.Find(p.Id); Assert.IsNotNull(target, "Found should not be null"); Assert.AreEqual(p.Id, target.Id, "Id didn't match"); Assert.AreEqual(p.StoreId, target.StoreId, "Store ID Didn't Match"); Assert.AreEqual("New", target.Name, "Name didn't match"); }
public void Promotion_CanUpdateNameOfPromotion() { var app = CreateHccAppInMemory(); var p = new Promotion(); p.Name = "Old"; var r = new PromotionRepository(new HccRequestContext()); r.Create(p); var updatedName = "New"; p.Name = updatedName; Assert.IsTrue(r.Update(p), "Update should be true"); var target = r.Find(p.Id); Assert.IsNotNull(target, "Found should not be null"); Assert.AreEqual(p.Id, target.Id, "Id didn't match"); Assert.AreEqual(p.StoreId, target.StoreId, "Store ID Didn't Match"); Assert.AreEqual("New", target.Name, "Name didn't match"); }
public void CanSaveQualificationsAndActionsInRepository() { Promotion p = new Promotion(); p.Name = "FindMe"; p.AddQualification(new ProductBvin("ABC123")); p.AddQualification(new ProductType("TYPE0")); p.AddAction(new ProductPriceAdjustment(AmountTypes.Percent, 50)); PromotionRepository r = PromotionRepository.InstantiateForMemory(new RequestContext()); Assert.IsTrue(r.Create(p), "Create should be true"); Assert.IsNotNull(p); Assert.IsTrue(p.Id > 0, "Promotion was not assigned an Id number"); Promotion target = r.Find(p.Id); Assert.IsNotNull(target, "Found should not be null"); Assert.AreEqual(p.Id, target.Id, "Id didn't match"); Assert.AreEqual(p.StoreId, target.StoreId, "Store ID Didn't Match"); Assert.AreEqual(p.Name, target.Name, "Name didn't match"); Assert.AreEqual(p.Qualifications.Count, target.Qualifications.Count, "Qualification count didn't match"); for (int i = 0; i < p.Qualifications.Count; i++) { Assert.AreEqual(p.Qualifications[0].Id, target.Qualifications[0].Id, "Id of index " + i.ToString() + " didn't match"); Assert.AreEqual(p.Qualifications[0].GetType(), target.Qualifications[0].GetType(), "Type of index " + i.ToString() + " didn't match"); } Assert.AreEqual(p.Actions.Count, target.Actions.Count, "Action count didn't match"); for (int i = 0; i < p.Actions.Count; i++) { Assert.AreEqual(p.Actions[0].Id, target.Actions[0].Id, "Id of action index " + i.ToString() + " didn't match"); Assert.AreEqual(p.Actions[0].GetType(), target.Actions[0].GetType(), "Type of action index " + i.ToString() + " didn't match"); } }
public void Create(Promotion entity) { PromotionRepository.Create(entity); }