public void GuestViewStock() { UserWatchStockInitialize(); MarketAnswer stockDetails = _storeBridgeGuest.ViewStoreStock("OOF"); WatchStockAndCompare(stockDetails); }
public void SuccessRemovingAProducFromStore() { MarketAnswer result2 = _storeManage1.RemoveProduct("bamba"); Assert.AreEqual((int)StoreEnum.Success, result2.Status); MarketAnswer stockAnswer = _storeBridge.ViewStoreStock("lokef"); string[] actualResult = stockAnswer.ReportList; Assert.AreEqual(0, actualResult.Length); }
public void AddDiscountAndReceiveItInOrderSuccessfully() { CheckNoDiscountAdded(); MarketAnswer res = _storeManagementBridge.AddDiscountToProduct("Ouch", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("20/04/2018"), 10, "VISIBLE", false); Assert.AreEqual((int)DiscountStatus.Success, res.Status); //check the discount was added to the product in the stock MarketAnswer stock = _storeShoppingBridge.ViewStoreStock("Toy"); string[] receivedStock = stock.ReportList; string[] expectedStock = { " name: Ouch base price: 30 description: Ouchouch Discount: {DiscountAmount: 10 Start Date: " + Convert.ToDateTime("14/04/2018").Date.ToString("d") + "" + " End Date: " + Convert.ToDateTime("20/04/2018").Date.ToString("d") + " type is: visible} Purchase Way: Immediate Quantity: 6" }; Assert.AreEqual(expectedStock.Length, receivedStock.Length); for (int i = 0; i < receivedStock.Length; i++) { Assert.AreEqual(expectedStock[i], receivedStock[i]); } SignUp(ref _userBuyer, "Vika", "Arad", "5555", "55555555"); _storeShoppingBridge2 = StoreShoppingDriver.getBridge(); _storeShoppingBridge2.GetStoreShoppingService(_userBuyer.GetUserSession()); _storeShoppingBridge2.AddProductToCart("Toy", "Ouch", 3); CreateOrder(); SignInAdminSystem(); MarketAnswer purchaseHistory = _userAdminBridge.ViewPurchaseHistoryByUser("Vika"); //make sure the price presented is after the discount string[] purchaseReceived = purchaseHistory.ReportList; string[] purchaseExpected = { "User: Vika Product: Ouch Store: Toy Sale: Immediate Quantity: 3 Price: 90 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy"), }; Assert.AreEqual(purchaseExpected.Length, purchaseReceived.Length); for (int i = 0; i < purchaseReceived.Length; i++) { Assert.AreEqual(purchaseExpected[i], purchaseReceived[i]); } }
public MarketAnswer ViewStoreStock(string store) { if (real != null) { return(real.ViewStoreStock(store)); } throw new NotImplementedException(); }
public void SuccessBuyingProductsRegisterUser() { AddProductsToCartRegisteredUser(); _orderBridge.GetOrderService(_buyerRegisteredUserBridge.GetUserSession()); MarketAnswer res = _orderBridge.BuyEverythingFromCart(new string[] { null, null }); Assert.AreEqual((int)OrderStatus.Success, res.Status); MarketAnswer puchaseHistory = _adminBridge.ViewPurchaseHistoryByUser("Shalom"); Assert.AreEqual((int)ViewPurchaseHistoryStatus.Success, puchaseHistory.Status); string[] receivedHistory = puchaseHistory.ReportList; string[] expectedHistory = { "User: Shalom Product: Coffee Store: HAHAHA Sale: Immediate Quantity: 3 Price: 30 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy"), "User: Shalom Product: Tea Store: Yalla Sale: Immediate Quantity: 4 Price: 40 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy") }; Assert.AreEqual(expectedHistory.Length, receivedHistory.Length); for (int i = 0; i < expectedHistory.Length; i++) { Assert.AreEqual(expectedHistory[i], receivedHistory[i]); } MarketAnswer cartDetails = _buyerRegisteredUserBridge.ViewCart(); string[] expectedCart = { }; string[] receivedCart = cartDetails.ReportList; Assert.AreEqual(expectedCart.Length, receivedCart.Length); MarketAnswer stock1 = _shoppingBridge.ViewStoreStock("Yalla"); string[] expectedYallaStock = { " name: Tea base price: 10 description: CherryFlavour Discount: {null} Purchase Way: Immediate Quantity: 2" }; Assert.AreEqual(expectedYallaStock[0], stock1.ReportList[0]); MarketAnswer stock2 = _shoppingBridge.ViewStoreStock("HAHAHA"); string[] expectedHahahaStock = { " name: Coffee base price: 10 description: Black Discount: {null} Purchase Way: Immediate Quantity: 3" }; Assert.AreEqual(expectedHahahaStock[0], stock2.ReportList[0]); }
public void DefineSuccessfullyVidibleDiscount() { CheckNoDiscountAdded(); MarketAnswer res = _storeManagementBridge.AddDiscountToProduct("Ouch", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("20/04/2018"), 10, "VISIBLE", false); Assert.AreEqual((int)DiscountStatus.Success, res.Status); //check the discount was added to the product in the stock MarketAnswer stock = _storeShoppingBridge.ViewStoreStock("Toy"); string[] receivedStock = stock.ReportList; string[] expectedStock = { " name: Ouch base price: 30 description: Ouchouch Discount: {DiscountAmount: 10 Start Date: " + Convert.ToDateTime("14/04/2018").Date.ToString("d") + "" + " End Date: " + Convert.ToDateTime("20/04/2018").Date.ToString("d") + " type is: visible} Purchase Way: Immediate Quantity: 6" }; Assert.AreEqual(expectedStock.Length, receivedStock.Length); for (int i = 0; i < receivedStock.Length; i++) { Assert.AreEqual(expectedStock[i], receivedStock[i]); } }
public void SuccessAddingProductToStore() { _storeManage1.GetStoreManagementService(_userBridge.GetUserSession(), "lokef"); MarketAnswer result = _storeManage1.AddNewProduct("bamba", 90, "nice snack", 30); Assert.AreEqual((int)StoreEnum.Success, result.Status); MarketAnswer stockAnswer = _storeBridge.ViewStoreStock("lokef"); string[] actualResult = stockAnswer.ReportList; string[] expectedResult = { " name: bamba base price: 90 description: nice snack Discount: {null} Purchase Way: Immediate Quantity: 30" }; Assert.AreEqual(expectedResult.Length, actualResult.Length); for (int i = 0; i < actualResult.Length; i++) { Assert.AreEqual(expectedResult[i], actualResult[i]); } }
private void AssertActions(bool[] permissions) { if (permissions[0]) { MarketAnswer res1 = _storeManager2.PromoteToStoreManager("Loki", storeAction1); Assert.AreEqual((int)PromoteStoreStatus.Success, res1.Status); } else { MarketAnswer res1 = _storeManager2.PromoteToStoreManager("Loki", storeAction1); Assert.AreEqual((int)PromoteStoreStatus.NoAuthority, res1.Status); } if (permissions[1]) { Assert.AreEqual((int)StoreEnum.Success, _storeManager2.AddNewProduct(product, 50, "tool", 5).Status); CheckProductAddedToStock(); Assert.AreEqual((int)StoreEnum.Success, _storeManager2.EditProduct(product, null, "3", null).Status); CheckProductEditedInStock(); Assert.AreEqual((int)StoreEnum.Success, _storeManager2.RemoveProduct(product).Status); MarketAnswer stock2 = _storeBridge.ViewStoreStock("Volcano"); Assert.AreEqual(0, stock2.ReportList.Length); } else { Assert.AreEqual((int)StoreEnum.NoPermission, _storeManager2.AddNewProduct(product, 50, "tool", 5).Status); Assert.AreEqual((int)StoreEnum.NoPermission, _storeManager2.EditProduct(product, "NewProduct1", "3", "HAHAH").Status); Assert.AreEqual((int)StoreEnum.NoPermission, _storeManager2.RemoveProduct(product).Status); } if (permissions[2]) { _storeManager1.AddNewProduct("Lets", 10, "haha", 10); Assert.AreEqual((int)DiscountStatus.Success, _storeManager2.AddDiscountToProduct("Lets", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("20/04/2018"), 5, "VISIBLE", false).Status); MarketAnswer stock = _storeBridge.ViewStoreStock("Volcano"); string[] receivedStock = stock.ReportList; string[] expectedStock = { " name: Lets base price: 10 description: haha Discount: {DiscountAmount: 5 Start Date: " + Convert.ToDateTime("14/04/2018").Date.ToString("d") + "" + " End Date: " + Convert.ToDateTime("20/04/2018").Date.ToString("d") + " type is: visible} Purchase Way: Immediate Quantity: 10" }; Assert.AreEqual(expectedStock.Length, receivedStock.Length); for (int i = 0; i < receivedStock.Length; i++) { Assert.AreEqual(expectedStock[i], receivedStock[i]); } } else { Assert.AreEqual((int)StoreEnum.NoPermission, _storeManager2.AddDiscountToProduct("Lets", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("20/04/2018"), 5, "VISIBLE", false).Status); } if (permissions[3]) { CreateOrder(); MarketAnswer purchaseHistory = _storeManager2.ViewStoreHistory(); string[] received = purchaseHistory.ReportList; string[] expected = { "User: Odin Product: Yolo Store: Volcano Sale: Immediate Quantity: 2 Price: 10 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy"), }; Assert.AreEqual(expected.Length, received.Length); for (int i = 0; i < received.Length; i++) { Assert.AreEqual(expected[i], received[i]); } } else { CreateOrder(); Assert.AreEqual((int)ManageStoreStatus.InvalidManager, _storeManager2.ViewStoreHistory().Status); } }
public void RegisteredUserViewStock() { MarketAnswer stockDetails = _storeBridge.ViewStoreStock("OOF"); WatchStockAndCompare(stockDetails); }
public void AddDiscountAndReceiveItInOrderSuccessfully() { //check there is no discount for ouch CheckNoDiscountAdded(); MarketAnswer res = _storeManagementBridge.AddDiscountToProduct("Ouch", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("20/04/2018"), 10, "HIDDEN", false); Assert.AreEqual((int)DiscountStatus.Success, res.Status); string coupon = res.ReportList[0]; //check the discount was added to the product in the stock MarketAnswer stock = _storeShoppingBridge.ViewStoreStock("Toy"); string[] receivedStock = stock.ReportList; string[] expectedStock = { " name: Ouch base price: 30 description: Ouchouch Discount: {type is: hidden} Purchase Way: Immediate Quantity: 6" }; Assert.AreEqual(expectedStock.Length, receivedStock.Length); for (int i = 0; i < receivedStock.Length; i++) { Assert.AreEqual(expectedStock[i], receivedStock[i]); } SignUp(ref _userBuyer, "Vika", "Arad", "5555", "55555555"); _storeShoppingBridge2 = StoreShoppingDriver.getBridge(); _storeShoppingBridge2.GetStoreShoppingService(_userBuyer.GetUserSession()); _storeShoppingBridge2.AddProductToCart("Toy", "Ouch", 3); //make sure the price in the cart is the original price MarketAnswer cartDetails = _userBuyer.ViewCart(); string[] receivedItems = cartDetails.ReportList; string[] expectedItems = { "Name : Ouch Store : Toy Quantity : 3 Unit Price : 30 Final Price : 90", }; Assert.AreEqual(expectedItems.Length, receivedItems.Length); for (int i = 0; i < receivedItems.Length; i++) { Assert.AreEqual(expectedItems[i], receivedItems[i]); } CreateOrderWithCoupon(coupon); SignInAdminSystem(); MarketAnswer purchaseHistory = _userAdminBridge.ViewPurchaseHistoryByUser("Vika"); //make sure the price presented is after the discount string[] purchaseReceived = purchaseHistory.ReportList; string[] purchaseExpected = { "User: Vika Product: Ouch Store: Toy Sale: Immediate Quantity: 2 Price: 40 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy"), }; Assert.AreEqual(purchaseExpected.Length, purchaseReceived.Length); for (int i = 0; i < purchaseReceived.Length; i++) { Assert.AreEqual(purchaseExpected[i], purchaseReceived[i]); } }
public void SuccessUpdatingProductName() { MarketAnswer result2 = _storeManage1.EditProduct("bamba", "bamba-osem", "90", "nice snack"); Assert.AreEqual((int)StoreEnum.Success, result2.Status); MarketAnswer stockAnswer = _storeBridge.ViewStoreStock("lokef"); string[] actualResult = stockAnswer.ReportList; string[] expectedResult = { " name: bamba-osem base price: 90 description: nice snack Discount: {null} Purchase Way: Immediate Quantity: 30" }; Assert.AreEqual(expectedResult.Length, actualResult.Length); for (int i = 0; i < actualResult.Length; i++) { Assert.AreEqual(expectedResult[i], actualResult[i]); } }