Exemplo n.º 1
0
        public void GetWarehouseFailWcf()
        {
            var prod = new Product
            {
                Id          = 1,
                Category    = "category",
                Description = "ddeskr",
                Name        = "banan",
                Price       = 10
            };

            var shop = new Shop
            {
                Id         = 1,
                Name       = "ShopName",
                Address    = "new addr",
                Chain      = new Chain(),
                Cvr        = "12121212",
                Warehouses = new List <Warehouse>()
            };

            var warehouse1 = new Warehouse(10, 5, prod, shop, 1);
            var warehouse2 = new Warehouse(10, 5, prod, shop, 1);

            using (var proxy = new BestilNemtServiceRef.BestilNemtServiceClient())
            {
                proxy.Open();
                var id1 = proxy.AddWarehouse(warehouse1);
                var id2 = proxy.AddWarehouse(warehouse2);
                proxy.DeleteWarehouse(id1);
                var rw = proxy.GetWarehouse(id1);
                proxy.DeleteWarehouse(id2);
                Assert.IsNull(rw);
            }
        }
Exemplo n.º 2
0
        public void UpdateWarehouseWcf()
        {
            var prod = new Product
            {
                Id          = 1,
                Category    = "category",
                Description = "ddeskr",
                Name        = "banan",
                Price       = 10
            };
            var shop = new Shop
            {
                Name        = "ShopName",
                Address     = "new addr",
                OpeningTime = "Manday Never",
                Chain       = new DbChain().GetChain(1),
                Cvr         = "12121212",
                Warehouses  = new List <Warehouse>()
            };
            var warehouseToUpdate = new Warehouse(1, 1, prod, shop, 1);

            using (var proxy = new BestilNemtServiceRef.BestilNemtServiceClient())
            {
                proxy.Open();
                var shopId = proxy.AddShop(shop);
                shop.Id = shopId;
                var id = proxy.AddWarehouse(warehouseToUpdate);
                warehouseToUpdate.Id = id;
                var warehouseNew = new Warehouse(id, 100, 50, prod, shop, 1);
                proxy.UpdateWarehouse(warehouseNew);
                var updatedWarehouse = proxy.GetWarehouse(id);
                proxy.DeleteWarehouse(id);
                Assert.AreEqual(warehouseNew.Stock, updatedWarehouse.Stock);
            }
        }
Exemplo n.º 3
0
        public void AddWarehouseWcf()
        {
            var prod = new Product
            {
                Id          = 1,
                Category    = "category",
                Description = "ddeskr",
                Name        = "banan",
                Price       = 10
            };
            var shop = new Shop
            {
                Name        = "ShopName",
                Address     = "new addr",
                OpeningTime = "Manday Never",
                Chain       = new Chain(),
                Cvr         = "12121212",
                Warehouses  = new List <Warehouse>()
            };

            using (var proxy = new BestilNemtServiceRef.BestilNemtServiceClient())
            {
                proxy.Open();
                var chain = proxy.GetChain(1);
                shop.Chain = chain;
                var shopId = proxy.AddShop(shop);
                shop.Id = shopId;
                var warehouse = new Warehouse(10, 5, prod, shop, 1);
                var id        = proxy.AddWarehouse(warehouse);
                proxy.DeleteWarehouse(id);
                Assert.AreNotEqual(0, id);
            }
        }