Ejemplo n.º 1
0
        public async Task Initialize()
        {
            ProxyMarketContext.Instance.IsDebug = false;
            String guestName = marketUsers.AddGuest();
            await userManagement.SignUp("founder", "123", null);

            await marketUsers.AddMember("founder", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("manager", "123", null);

            await marketUsers.AddMember("manager", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("owner", "123", null);

            await marketUsers.AddMember("owner", "123", guestName);

            Address    address = new Address("1", "1", "1", "1", "1");
            CreditCard card    = new CreditCard("1", "1", "1", "1", "1", "1");

            store = await market.CreateStore("testStore", "founder", card, address);

            await market.makeManager("manager", store.Id, "founder");

            await market.makeOwner("owner", store.Id, "founder");
        }
Ejemplo n.º 2
0
        public async Task MarketRulesTestsInit()
        {
            ProxyMarketContext.Instance.IsDebug = false;
            String guestName = marketUsers.AddGuest();
            await userManagement.SignUp("founder", "123", null);

            await marketUsers.AddMember("founder", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("manager", "123", null);

            await marketUsers.AddMember("manager", "123", guestName);

            Address    address = new Address("1", "1", "1", "1", "1");
            CreditCard card    = new CreditCard("1", "1", "1", "1", "1", "1");

            store = await marketStores.CreateStore("testStore", "founder", card, address);

            await marketStores.makeManager("manager", store.Id, "founder");

            product1 = new ProductData(new Guid(), "ProductName", 100, 100, 100, "CategoryName");
            User         u    = marketUsers.GetUserByUserName("founder");
            ShoppingCart cart = u.ShoppingCart;

            shoppingBasket = await cart.GetShoppingBasket(store);

            Result <Product> result = await MarketStores.Instance.AddProduct(product1, store.Id, "founder");

            product = result.Ret;
            await marketUsers.AddProductToCart("founder", result.Ret.Id, 10);
        }
        public async Task AddProductInCartSuccessAsync()
        {
            ProxyMarketContext.Instance.IsDebug = true;
            string username            = m.AddGuest();
            User   u                   = m.GetUserByUserName(username);
            Mock <ShoppingCart>   cart = new Mock <ShoppingCart>();
            Mock <ShoppingBasket> bask = new Mock <ShoppingBasket>();

            cart.Setup(c => c.GetShoppingBasket(It.IsAny <Store>())).Returns(Task.FromResult(bask.Object));
            bask.Setup(b => b.addProduct(It.IsAny <Product>(), It.IsAny <int>())).Returns(Task.FromResult("product added to shopping basket"));
            u.ShoppingCart = cart.Object;
            Product p = new Product(new Guid(), "lala", 8, 50, 500, "category");
            Store   s = new Store("lalali", null, null);

            s.Products.Add(p);
            marketStores.LoadedStores.TryAdd(s.GetId(), s);
            Assert.AreEqual("product added to shopping basket", await m.AddProductToCart(username, p.Id, 5));
        }
Ejemplo n.º 4
0
        public async Task AddProductSuccess()
        {
            string       username = m.AddGuest();
            User         u        = m.GetUserByUserName(username);
            ShoppingCart cart     = new ShoppingCart(u);

            u.ShoppingCart = cart;
            Product p = new Product(new Guid(), "lala", 8, 50, 500, "category");
            Store   s = new Store("lalali", null, null);

            s.Products.Add(p);
            marketStores.LoadedStores.TryAdd(s.GetId(), s);
            Assert.AreEqual("product added to shopping basket", await m.AddProductToCart(username, p.Id, 5));
            ShoppingBasket b = await cart.GetShoppingBasket(s);

            Assert.IsTrue(b.GetProducts().Contains(p));
            Assert.AreEqual(b.GetProductQuantity(p), 5);
        }
Ejemplo n.º 5
0
        public async Task Initialize()
        {
            ProxyMarketContext.Instance.IsDebug = false;

            PublisherManagement.Instance.DeleteAll();
            publisherManagement = PublisherManagement.Instance;
            publisherManagement.SetTestMode(true);
            String guestName = marketUsers.AddGuest();
            await userManagement.SignUp("FounderTest1", "123", null);

            await marketUsers.AddMember("FounderTest1", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("ManagerTest1", "123", null);

            await marketUsers.AddMember("ManagerTest1", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("OwnerTest1", "123", null);

            await marketUsers.AddMember("OwnerTest1", "123", guestName);

            Address    address = new Address("1", "1", "1", "1", "1");
            CreditCard card    = new CreditCard("1", "1", "1", "1", "1", "1");

            store = await market.CreateStore("testStore", "FounderTest1", card, address);

            await market.makeOwner("OwnerTest1", store.Id, "FounderTest1");

            owner    = marketUsers.ActiveUsers.GetOrAdd("OwnerTest1", owner);
            customer = marketUsers.ActiveUsers.GetOrAdd("ManagerTest1", customer);

            dataproduct = new ProductData(new Guid(), "lala", 100, 100, 100, "cat");
            var shoppingCart     = new ShoppingCart(customer);
            Result <Product> res = await market.AddProduct(dataproduct, store.Id, "FounderTest1");

            product = res.Ret;
            await marketUsers.AddProductToCart(customer.Username, product.id, QUANTITY);
        }
        public async Task Initialize()
        {
            ProxyMarketContext.Instance.IsDebug = true;

            PublisherManagement.Instance.DeleteAll();
            marketUsers.CleanMarketUsers();
            publisherManagement = PublisherManagement.Instance;
            publisherManagement.SetTestMode(true);
            String guestName = marketUsers.AddGuest();
            await userManagement.SignUp("FounderTest1", "123", null);

            await marketUsers.AddMember("FounderTest1", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("ManagerTest1", "123", null);

            await marketUsers.AddMember("ManagerTest1", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("OwnerTest1", "123", null);

            await marketUsers.AddMember("OwnerTest1", "123", guestName);

            Address    address = new Address("1", "1", "1", "1", "1");
            CreditCard card    = new CreditCard("1", "1", "1", "1", "1", "1");

            store = await market.CreateStore("testStore", "FounderTest1", card, address);

            await market.makeOwner("OwnerTest1", store.Id, "FounderTest1");

            owner    = marketUsers.ActiveUsers.GetOrAdd("OwnerTest1", owner);
            customer = marketUsers.ActiveUsers.GetOrAdd("ManagerTest1", customer);
            product  = new Product(new Guid(), 100, 100, 100);
            var shoppingCart = new ShoppingCart(customer);
            await customer.UpdateProductInShoppingBasket(store, product, QUANTITY);

            store.UpdateProduct(product);
        }
 //returns uniqe username for guest
 public string AddGuest()
 {
     return(marketUsers.AddGuest());
 }
        public async Task Initialize()
        {
            String guestName = marketUsers.AddGuest();
            await userManagement.SignUp("founder", "123", null);

            await marketUsers.AddMember("founder", "123", guestName);

            guestName = marketUsers.AddGuest();
            await userManagement.SignUp("manager", "123", null);

            await marketUsers.AddMember("manager", "123", guestName);

            Address    address = new Address("1", "1", "1", "1", "1");
            CreditCard card    = new CreditCard("1", "1", "1", "1", "1", "1");

            store = await market.CreateStore("testStore", "founder", card, address);

            await market.makeManager("manager", store.Id, "founder");

            product1 = new ProductData(new Guid(), "1", 10, 10, 10, "c");
        }