Ejemplo n.º 1
0
        public void ShipOrder_Success()
        {
            //Arrange
            var order = new Order(Guid.NewGuid(), "Test order")
            {
                ItemsOrdered = new HashSet <InventoryItem>()
                {
                    new InventoryItem(Product1InteriorDoor, 5),
                },
                ItemsProduced = new HashSet <InventoryItem>()
                {
                    InventoryItem.Empty(Product1InteriorDoor),
                }
            };
            var shop = ProductStockpileShop.DeepCopy();

            shop.Orders = new HashSet <Order>()
            {
                order
            };
            order.Shop = shop;


            //Act
            OrderService.ShipOrder(order);

            //Assert
            Assert.That(order.Status, Is.EqualTo(OrderStatus.Shipped));
            Assert.That(order.ShippedAt, Is.Not.Null);
        }
Ejemplo n.º 2
0
        public void TransferInventory_Success()
        {
            decimal initialSource = 10;
            decimal initialTarget = 2;
            //arrange
            var source = ProductAssemblyShop.DeepCopy();

            source.Inventory = new HashSet <InventoryItem>()
            {
                new InventoryItem(Product1InteriorDoor, initialSource)
            };
            var target = ProductStockpileShop.DeepCopy();

            target.Inventory = new HashSet <InventoryItem>()
            {
                new InventoryItem(Product1InteriorDoor, initialTarget)
            };
            var item = new InventoryItem(Product1InteriorDoor, 2);

            //act
            InventoryService.Transfer(source, target, item);

            //assert
            var actualSource = source.Inventory.Of(Product1InteriorDoor).Amount;

            Assert.That(actualSource, Is.EqualTo(initialSource - item.Amount));

            var actualTarget = target.Inventory.Of(Product1InteriorDoor).Amount;

            Assert.That(actualTarget, Is.EqualTo(initialTarget + item.Amount));
        }
Ejemplo n.º 3
0
        public void TransferInventory_FailFor_ArticleNotAllowedInShop()
        {
            //arrange
            var source = MaterialStockpileShop.DeepCopy();
            var target = ProductStockpileShop.DeepCopy();
            var item   = new InventoryItem(Material1Timber, 1);

            //assert () => act
            var ex = Assert.Throws <DomainException>(() => InventoryService.Transfer(source, target, item));

            Assert.That(ex.Message, Is.EqualTo(ArticleNotAllowedInShop(item.Article, target)));
        }
Ejemplo n.º 4
0
        public void TransferInventory_FailFor_ArticleNotInStock()
        {
            //arrange
            var source = ProductAssemblyShop.DeepCopy();

            source.Inventory = new HashSet <InventoryItem>();
            var target = ProductStockpileShop.DeepCopy();
            var item   = new InventoryItem(Product1InteriorDoor, 2);

            //assert ()=> act
            var ex = Assert.Throws <DomainException>(() => InventoryService.Transfer(source, target, item));

            Assert.That(ex.Message, Is.EqualTo(ArticleNotInStock(Product1InteriorDoor, source)));
        }
Ejemplo n.º 5
0
        public void TransferInventory_FailFor_InsufficientInventory()
        {
            decimal initialP1 = 2;
            //arrange
            var source = ProductAssemblyShop.DeepCopy();

            source.Inventory = new HashSet <InventoryItem>()
            {
                new InventoryItem(Product1InteriorDoor, initialP1)
            };
            var target = ProductStockpileShop.DeepCopy();
            var item   = new InventoryItem(Product1InteriorDoor, 10);

            //assert ()=> act
            var ex = Assert.Throws <DomainException>(() => InventoryService.Transfer(source, target, item));

            Assert.That(ex.Message, Is.EqualTo(InsufficientInventory(Product1InteriorDoor, item.Amount, initialP1)));
        }
Ejemplo n.º 6
0
        private void InitShopCategories()
        {
            TimberComponentShopCategory.Shops = TimberComponentShop.CollectToHashSet();
            TimberComponentShopCategory.Articles.Add(Material1Timber);
            TimberComponentShopCategory.Articles.Add(Material2Foil);
            TimberComponentShopCategory.Articles.Add(Component1Vertical);
            TimberComponentShopCategory.Articles.Add(Component2Horizontal);

            MdfComponentShopCategory.Shops = MdfComponentShop.CollectToHashSet();
            MdfComponentShopCategory.Articles.Add(Material3Mdf);
            MdfComponentShopCategory.Articles.Add(Material2Foil);
            MdfComponentShopCategory.Articles.Add(Component3MdfFiller);

            GlassComponentShopCategory.Articles.Add(Material4TintedGlass);
            GlassComponentShopCategory.Articles.Add(Component4GlassFiller);
            GlassComponentShopCategory.Shops = GlassComponentShop.CollectToHashSet();

            ProductAssemblyShopCategory.Articles.Add(Component1Vertical);
            ProductAssemblyShopCategory.Articles.Add(Component2Horizontal);
            ProductAssemblyShopCategory.Articles.Add(Component3MdfFiller);
            ProductAssemblyShopCategory.Articles.Add(Component4GlassFiller);
            ProductAssemblyShopCategory.Articles.Add(Product1InteriorDoor);
            ProductAssemblyShopCategory.Articles.Add(Product2InteriorDoor);
            ProductAssemblyShopCategory.Articles.Add(Component1VerticalSpoiled);
            ProductAssemblyShopCategory.Articles.Add(Product1InteriorDoorSpoiled);
            ProductAssemblyShopCategory.Shops = ProductAssemblyShop.CollectToHashSet();

            MaterialStockpileShopCategory.Articles.Add(Material1Timber);
            MaterialStockpileShopCategory.Articles.Add(Material2Foil);
            MaterialStockpileShopCategory.Articles.Add(Material3Mdf);
            MaterialStockpileShopCategory.Articles.Add(Material4TintedGlass);
            MaterialStockpileShopCategory.Shops = MaterialStockpileShop.CollectToHashSet();

            ProductStockpileShopCategory.Articles.Add(Product1InteriorDoor);
            ProductStockpileShopCategory.Articles.Add(Product2InteriorDoor);
            ProductStockpileShopCategory.Shops = ProductStockpileShop.CollectToHashSet();

            ShopCategoryToArchive.Shops = ShopToRemove.CollectToHashSet();
            ShopCategoryToArchive.Articles.Add(ArticleToArchive);
        }