public void KreirajKorisnikaIstiUsername() { OnlineStore prodavnica = new OnlineStore("pozz"); prodavnica.registrirajKorisnika("Amir", "Muminovic", DateTime.Now, "4024007195736334", "amuminovic", "<3-VVS-<3"); prodavnica.registrirajKorisnika("Amir", "Muminovic", DateTime.Now, "4024007195736334", "amuminovic", "<3-VVS-<3"); }
public void PretragaNepostojeceImePrezime() { OnlineStore prodavnica = new OnlineStore("pozz"); prodavnica.registrirajKorisnika("Amir", "Muminovic", DateTime.Now, "4024007195736334", "amuminovic", "<3-VVS-<3"); prodavnica.pretragaKorisnikaPoImenu("Samir", "Muminovic"); }
public UserController registerStoreOwnerForOnlineStore(string email, string userName, string password, string storeName, string storeURL, [FromBody] string value) { UserController user = userFinder.findUser(email); if (user != null) { return(null); } Store store = onlineStoreSearcher.searchStoreByName(storeName); if (store != null) { return(null); } StoreOwnerController storeOwnerUser = new StoreOwnerController(email, userName, password); OnlineStore onlineStore = new OnlineStore(storeName, storeURL, storeOwnerUser.getStoreOwner()); onlineStoreAdder.addStore(onlineStore); storeOwnerUser.addStore(onlineStore); storeOwnerRepo.addUser(storeOwnerUser.getStoreOwner()); return(storeOwnerUser); }
public void Add_StoreInventory() { var store = new OnlineStore(new Catalog()); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.Tent), 9); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.SleepingBag), 3); }
public void PretragaPjesmeNazivIzvodjac() { OnlineStore prodavnica = new OnlineStore("pozz"); prodavnica.registrujNovuPjesmu(new Tune("Hallowed Be Thy Name", "Iron Maiden", "The Number Of The Beast", "Metal", 10.0, ".mp3", 433, 256, 70.11)); prodavnica.pretragaPjesamaPoNazivuIzvodacu("Master Of Puppets", "Metallica"); }
public void AddMoreItemsThanInventoryToCart_Expecting_Exception() { var store = new OnlineStore(new Catalog()); const string customerName = CustomerName; store.CreateShoppingCart(customerName); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 10); // only have 9 tents in the inventory }
public void UnaprijediGoldMembera() { OnlineStore prodavnica = new OnlineStore("pozz"); prodavnica.registrirajKorisnika("Amir", "Muminovic", DateTime.Now, "4024007195736334", "amuminovic", "<3-VVS-<3"); prodavnica.RegMembers[0].GoldMember = true; prodavnica.unaprijediNaGoldMember(prodavnica.RegMembers[0].Id); }
public void RemoveMoreItemsFromCart_Expecting_Exception() { var store = new OnlineStore(new Catalog()); const string customerName = CustomerName; store.CreateShoppingCart(customerName); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 8); store.RemoveItemFromShoppingCart(customerName, ProductTypeEnum.Tent, 10); }
public void AddItemToCart_MutipleCalls_Should_Total() { var store = new OnlineStore(new Catalog()); var customerName = CustomerName; store.CreateShoppingCart(customerName); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 3); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 2); Assert.AreEqual(5, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent)); Assert.AreEqual(5 * 50M, store.GetItemInCart(customerName, ProductTypeEnum.Tent).Cost); }
public void CheckoutCart_LessThan200_DefaultShippingCost() { var store = new OnlineStore(new Catalog()); store.CreateShoppingCart(CustomerName); // 11*1 = 11kg overweight, $25 overweight charge applies store.AddItemToShoppingCart(CustomerName, ProductTypeEnum.Stove, 3); //$120 Assert.AreEqual(3, store.GetItemCountInCart(CustomerName, ProductTypeEnum.Stove)); Assert.AreEqual(120M + 20M, store.CheckoutShoppingCart(CustomerName)); // price = $120+$20 }
public void CheckoutCart_Over200_Overweight() { var store = new OnlineStore(new Catalog()); store.CreateShoppingCart(CustomerName); // 11*1 = 11kg overweight, $25 overweight charge applies store.AddItemToShoppingCart(CustomerName, ProductTypeEnum.Stove, 11); Assert.AreEqual(11, store.GetItemCountInCart(CustomerName, ProductTypeEnum.Stove)); Assert.AreEqual(465M, store.CheckoutShoppingCart(CustomerName)); // price = 11*40 + 25 }
public void CheckoutCart_Over200_WaiveShippingCost_OverweightNotApply() { var store = new OnlineStore(new Catalog()); const string customerName = CustomerName; store.CreateShoppingCart(customerName); // 6*1 = 6kg not overweight, $25 overweight charge not appluy store.AddItemToShoppingCart(customerName, ProductTypeEnum.Stove, 6); //$240 Assert.AreEqual(6, store.GetItemCountInCart(customerName, ProductTypeEnum.Stove)); Assert.AreEqual(240M, store.CheckoutShoppingCart(customerName)); // price = $240 }
public void CheckoutCart_LessThan200_Overweight() { var store = new OnlineStore(new Catalog()); store.CreateShoppingCart(CustomerName); // 11*1 = 11kg overweight, $25 overweight charge applies, price is $55, less than $200 store.AddItemToShoppingCart(CustomerName, ProductTypeEnum.DehydratedMeal, 11); Assert.AreEqual(11, store.GetItemCountInCart(CustomerName, ProductTypeEnum.DehydratedMeal)); Assert.AreEqual(55M + 25M + 20M, store.CheckoutShoppingCart(CustomerName)); // price = 11*5 + $25 OW+ $20 Default Charge }
public void Initialize_StoreInventory() { var store = new OnlineStore(new Catalog()); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.Tent), 9); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.SleepingBag), 3); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.Backpack), 7); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.Stove), 16); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.GranolaBar), 30); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.TrailMix), 19); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.DehydratedMeal), 30); Assert.AreEqual(store.CheckInventory(ProductTypeEnum.Coffee), 42); }
public void RegistrujKorisnikeTest() { OnlineStore o = new OnlineStore("banana"); o.registrirajKorisnika(Convert.ToString(TestContext.DataRow["ime"]), Convert.ToString(TestContext.DataRow["prezime"]), Convert.ToDateTime(TestContext.DataRow["datumRodjenja"]), Convert.ToString(TestContext.DataRow["bkk"]), Convert.ToString(TestContext.DataRow["username"]), Convert.ToString(TestContext.DataRow["password"])); Assert.IsTrue(o.RegMembers[o.RegMembers.Count - 1].Ime == Convert.ToString(TestContext.DataRow["ime"])); Assert.IsTrue(o.RegMembers[o.RegMembers.Count - 1].Prezime == Convert.ToString(TestContext.DataRow["prezime"])); }
public static void PripremaZaTest(TestContext t) { testniStore = new OnlineStore("/"); testniStore.registrirajKorisnika("Amir", "Muminovic", DateTime.Now, "4012888888881881", "amuminovic", "VVSJeTop"); testniStore.registrirajKorisnika("Haris", "Masovic", DateTime.Now, "4024007195736334", "hmasovic", "HarisVoliSabana"); testniStore.registrirajKorisnika("Bill", "Gates", DateTime.Now, "6011816573426759", "bgates", "C#FTW"); testniStore.registrujNovuPjesmu(new Tune("Hallowed Be Thy Name", "Iron Maiden", "The Number Of The Beast", "Metal", 10.0, ".mp3", 433, 256, 70.11)); testniStore.registrujNovuPjesmu(new Tune("Nothing else matters", "Metallica", "Metallica", "Metal", 9.5, ".mp3", 350, 256, 2.11)); testniStore.registrujNovuPjesmu(new Tune("Run", "Foo Fighters", "Gold and Concrete", "Rock", 9.9, ".mp3", 413, 256, 5.05)); testniStore.registrujNovuPjesmu(new Tune("Dumb", "Nirvana", "In Utero", "Rock", 9.0, ".mp3", 233, 256, 4.11)); testniStore.registrujNovuPjesmu(new Tune("Kraljice srca moga", "Saban", "Single", "Folk", 2.0, ".mp3", 211, 256, 0)); //Free pjesma testniStore.registrujNovuPjesmu(new Tune("Nyan Cat", "Internet", "Single", "Techno", 11.0, ".mp3", 233, 256, -5)); // Pjesma koja daje pare }
public void CheckoutCart_Over3Tents_15PercentDiscount() { var store = new OnlineStore(new Catalog()); const string customerName = CustomerName; store.CreateShoppingCart(customerName); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 5); //$5*$50 store.AddItemToShoppingCart(customerName, ProductTypeEnum.DehydratedMeal, 10); //10*5 Assert.AreEqual(5, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent)); Assert.AreEqual(10, store.GetItemCountInCart(customerName, ProductTypeEnum.DehydratedMeal)); // price = 5*$50 + $25 + $5*10 // 5*2.5 = 12.5kg 'overweight, $25 overweight charge apply Assert.AreEqual((5 * 50M + 10 * 5M) * .85M + 25M, store.CheckoutShoppingCart(customerName)); }
public void CheckoutCart_Detailed() { var store = new OnlineStore(new Catalog()); const string customerName = CustomerName; store.CreateShoppingCart(customerName); // 11*1 = 11kg overweight, $25 overweight charge applies store.AddItemToShoppingCart(customerName, ProductTypeEnum.Stove, 3); //$120 Assert.AreEqual(3, store.GetItemCountInCart(customerName, ProductTypeEnum.Stove)); var shoppingCart = store.CheckoutShoppingCart(customerName, true); Assert.AreEqual(120, shoppingCart.SubTotal); Assert.AreEqual(20, shoppingCart.ShippingFees); Assert.AreEqual(140, shoppingCart.Total); Assert.AreEqual(0, shoppingCart.Discounts); }
public void AddItemToCart_TakeoutFromInventory() { var store = new OnlineStore(new Catalog()); var customerName = CustomerName; store.CreateShoppingCart(customerName); bool hasInventory = store.CheckInventory(ProductTypeEnum.Tent) >= 10; Assert.IsFalse(hasInventory); hasInventory = store.CheckInventory(ProductTypeEnum.Tent) >= 5; Assert.IsTrue(hasInventory); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 5); int tentInInventory = store.CheckInventory(ProductTypeEnum.Tent); Assert.AreEqual(tentInInventory, 4); Assert.AreEqual(5, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent)); }
public void DropShoppingCart_Should_ZeroOutCart_RestoreInventory() { var store = new OnlineStore(new Catalog()); var customerName = CustomerName; store.CreateShoppingCart(customerName); var originalTotalInventory = Catalog.GetTotalProducts(); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 3); Assert.AreEqual(originalTotalInventory - 3, Catalog.GetTotalProducts()); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Backpack, 2); Assert.AreEqual(originalTotalInventory - 3 - 2, Catalog.GetTotalProducts()); Assert.AreEqual(3, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent)); Assert.AreEqual(2, store.GetItemCountInCart(customerName, ProductTypeEnum.Backpack)); store.DropShoppingCart(customerName); Assert.AreEqual(store.GetItemCountInCart(customerName, ProductTypeEnum.Tent), 0); Assert.AreEqual(store.GetItemCountInCart(customerName, ProductTypeEnum.Backpack), 0); // total inventory changed back Assert.AreEqual(originalTotalInventory, Catalog.GetTotalProducts()); }
public void RemoveItemFromCart_ReturnsToInventory() { var store = new OnlineStore(new Catalog()); var customerName = CustomerName; store.CreateShoppingCart(customerName); bool hasInventory = store.CheckInventory(ProductTypeEnum.Tent) >= 5; Assert.IsTrue(hasInventory); store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 5); int tentInInventory = store.CheckInventory(ProductTypeEnum.Tent); Assert.AreEqual(tentInInventory, 4); Assert.AreEqual(5, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent)); // now take one item from cart store.RemoveItemFromShoppingCart(customerName, ProductTypeEnum.Tent, 1); // show be 4 left in cart Assert.AreEqual(4, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent)); // inventory should have 5 tentInInventory = store.CheckInventory(ProductTypeEnum.Tent); Assert.AreEqual(tentInInventory, 5); }
public ChatHub(UserContext userContext, CommentStore commentStore, OnlineStore onlineStore) { _userContext = userContext; _commentStore = commentStore; _onlineStore = onlineStore; }
public void AddOnlineStore(OnlineStore onlineStore) { _storeContext.OnlineStores.Add(onlineStore); _storeContext.SaveChanges(); }