public string RegisterStorage(string type, string name)
        {
            //Creating new newStorage variable of Storage class
            Storage newStorage;                            //

            if (type == "AutomatedWarehouse")              //when the type is AutomatedWarehouse..
            {
                newStorage = new AutomatedWarehouse(name); //Creating new AutomatedWarehouse with that name
                storages.Add(newStorage);                  //We add the new AutomatedWarhouse to the storages list
                return($"Registred {name}");               //we print out the new AutoWarehouse name that is added.
            }
            else if (type == "DistributionCenter")
            {
                newStorage = new DistributionCenter(name);
                storages.Add(newStorage);
                return($"Registred {name}");
            }
            else if (type == "Warehouse")
            {
                newStorage = new Warehouse(name);
                storages.Add(newStorage);
                return($"Registred {name}");
            }
            throw new NotImplementedException("Invalide storage type!");
        }
        public string RegisterStorage(string type, string name)
        {
            Storage currentStorage;

            switch (type)
            {
            case "AutomatedWarehouse":
                currentStorage = new AutomatedWarehouse(name);
                break;

            case "DistributionCenter":
                currentStorage = new DistributionCenter(name);
                break;

            case "Warehouse":
                currentStorage = new Warehouse(name);
                break;

            default:
                throw new InvalidOperationException(ErrorMessage.InvalidStoradeType);
            }

            storageRegistry.Add(currentStorage);

            return($"Registered {name}");
        }
Beispiel #3
0
        public Storage CreateStorage(string type, string name)
        {
            Storage storage = null;

            switch (type)
            {
            case "AutomatedWarehouse":
                storage = new AutomatedWarehouse(name);
                break;

            case "DistributionCenter":
                storage = new DistributionCenter(name);
                break;

            case "Warehouse":
                storage = new Warehouse(name);
                break;

            default:
                throw new InvalidOperationException(
                          string.Format(
                              ExceptionMessages.InvalidType,
                              "storage"));
            }

            return(storage);
        }
Beispiel #4
0
        public void TestWarehouseSendVehicleSendsVehiclesAndReturnsTheCorrectSlot()
        {
            var warehouse          = new Warehouse("SmartSolutions");
            var automatedWarehouse = new AutomatedWarehouse("SmartTech");

            Assert.AreEqual(warehouse.SendVehicleTo(0, automatedWarehouse), 1, "Doesnt return the correct added slot from delivery location.");
        }
        public Storage CreateStorage(string type, string name)
        {
            Storage storage = null;

            if (type == "Warehouse")
            {
                storage = new Warehouse(name);
            }
            else if (type == "DistributionCenter")
            {
                storage = new DistributionCenter(name);
            }
            else if (type == "AutomatedWarehouse")
            {
                storage = new AutomatedWarehouse(name);
            }

            if (storage != null)
            {
                return(storage);
            }
            else
            {
                throw new InvalidOperationException("Invalid storage type!");
            }
        }
        public string RegisterStorage(string type, string name)
        {
            Storage storage;

            switch (type)
            {
            case "AutomatedWarehouse":
                storage = new AutomatedWarehouse(name);
                break;

            case "DistributionCenter":
                storage = new DistributionCenter(name);
                break;

            case "Warehouse":
                storage = new Warehouse(name);
                break;

            default:
                throw new InvalidOperationException("Invalid storage type!");
            }

            this.storages.Add(name, storage);

            return($"Registered {name}");
        }
        public void TestDistributionCenterSendVehicleSendsVehiclesAndReturnsTheCorrectSlot()
        {
            var distributionCenter          = new DistributionCenter("SmartSolutions");
            var automatedDistributionCenter = new AutomatedWarehouse("SmartTech");

            Assert.AreEqual(distributionCenter.SendVehicleTo(0, automatedDistributionCenter), 1, "Doesnt return the correct added slot from delivery location.");
        }
Beispiel #8
0
        public Storage CreateStorage(string type, string name)
        {
            type = type.ToLower();
            Storage storage = null;

            switch (type)
            {
            case "automatedwarehouse":
                storage = new AutomatedWarehouse(name);
                break;

            case "distributioncenter":
                storage = new DistributionCenter(name);
                break;

            case "warehouse":
                storage = new Warehouse(name);
                break;

            default:
                throw new InvalidOperationException("Invalid storage type!");
            }

            return(storage);
        }
Beispiel #9
0
        public void SendVehicleToMethodWorksCorrectly()
        {
            Storage targetStorage     = new AutomatedWarehouse("TargetStorage");
            int     expectedSlotIndex = 1;

            Assert.AreEqual(expectedSlotIndex, storage.SendVehicleTo(0, targetStorage));
        }
        public void Constructor_ShouldInitializeCorrectly()
        {
            Storage warehouse = new AutomatedWarehouse("house");

            Assert.AreEqual(2, warehouse.GarageSlots);
            Assert.AreEqual(1, warehouse.Capacity);
            Assert.AreEqual(1, this.automatedWarehouse.Garage.Count(v => v != null));
        }
Beispiel #11
0
        public void DoesSendVehicleThrow()
        {
            var dest = new AutomatedWarehouse("Basisklado");

            this.stor.SendVehicleTo(1, dest);

            Assert.Throws <InvalidOperationException>(() => this.stor.SendVehicleTo(0, dest));
        }
Beispiel #12
0
        public void TestWarehouseSendVehicleSendsVehiclesAndSetsTheDeliveryLocationCorrectly()
        {
            var warehouse          = new Warehouse("SmartSolutions");
            var automatedWarehouse = new AutomatedWarehouse("SmartTech");

            warehouse.SendVehicleTo(0, automatedWarehouse);

            Assert.AreEqual(automatedWarehouse.Garage.ElementAt(1).GetType().Name, typeof(Semi).Name, "When sending vehicles doesnt reflect in the delivery Storage.");
        }
        public void TestDistributionCenterSendVehicleSendsVehiclesAndSetsTheDeliveryLocationCorrectly()
        {
            var distributionCenter          = new DistributionCenter("SmartSolutions");
            var automatedDistributionCenter = new AutomatedWarehouse("SmartTech");

            distributionCenter.SendVehicleTo(0, automatedDistributionCenter);

            Assert.AreEqual(automatedDistributionCenter.Garage.ElementAt(1).GetType().Name, typeof(Van).Name, "When sending vehicles doesnt reflect in the delivery Storage.");
        }
Beispiel #14
0
        public void TestAutomatedWarehousePropertyIsFullReturnsFalse()
        {
            var automatedWarehouse = new AutomatedWarehouse("SmartSolutions");
            var ram = new Ram(123);

            automatedWarehouse.GetVehicle(0).LoadProduct(ram);
            automatedWarehouse.UnloadVehicle(0);
            Assert.IsFalse(automatedWarehouse.IsFull, "AutomatedWarehouse should not be full.");
        }
        public void SendVehicleToShouldReturnProperAddedSlot()
        {
            int garageSlot       = 1;
            var vehicle          = this.warehouse.GetVehicle(0);
            var deliveryLocation = new AutomatedWarehouse("Baumax");
            var addedSlot        = warehouse.SendVehicleTo(garageSlot, deliveryLocation);

            Assert.That(addedSlot == garageSlot);
        }
        public void SendVehicleToShouldReturnProperAddedSlot()
        {
            int garageSlot       = 0;
            var vehicle          = this.automatedWarehouse.GetVehicle(0);
            var deliveryLocation = new AutomatedWarehouse("MrBricoulage");
            var addedSlot        = automatedWarehouse.SendVehicleTo(garageSlot, deliveryLocation);

            Assert.That(addedSlot == 1);
        }
Beispiel #17
0
        public void TestAutomatedWarehouseProperyProductsReturnsTheCorrectElements()
        {
            var automatedWarehouse = new AutomatedWarehouse("SmartSolutions");
            var hardDirve          = new HardDrive(123);

            automatedWarehouse.GetVehicle(0).LoadProduct(hardDirve);
            automatedWarehouse.UnloadVehicle(0);
            Assert.AreEqual(automatedWarehouse.Products.ElementAt(0), hardDirve, "Product is not the same as expected.");
        }
Beispiel #18
0
        public void TestWarehouseSendVehicleSendsVehicles()
        {
            var warehouse          = new Warehouse("SmartSolutions");
            var automatedWarehouse = new AutomatedWarehouse("SmartTech");

            warehouse.SendVehicleTo(0, automatedWarehouse);

            Assert.AreEqual(warehouse.Garage.ElementAt(0), null, "When sending vehicles doesnt reflect in the current Storage.");
        }
Beispiel #19
0
        public void TestAutomatedWarehousePropertyIsFullReturnsTrue()
        {
            var automatedWarehouse = new AutomatedWarehouse("SmartSolutions");
            var hardDirve          = new HardDrive(123);

            automatedWarehouse.GetVehicle(0).LoadProduct(hardDirve);
            automatedWarehouse.UnloadVehicle(0);
            Assert.IsTrue(automatedWarehouse.IsFull, "AutomatedWarehouse should be full.");
        }
        public void TestDistributionCenterSendVehicleSendsVehicles()
        {
            var distributionCenter          = new DistributionCenter("SmartSolutions");
            var automatedDistributionCenter = new AutomatedWarehouse("SmartTech");

            distributionCenter.SendVehicleTo(0, automatedDistributionCenter);

            Assert.AreEqual(distributionCenter.Garage.ElementAt(0), null, "When sending vehicles doesnt reflect in the current Storage.");
        }
        public void TestDistributionCenterThrowsExceptionWhenDeliveryLocationIsfull()
        {
            var distributionCenter          = new DistributionCenter("SmartSolutions");
            var automatedDistributionCenter = new AutomatedWarehouse("SmartTech");

            distributionCenter.SendVehicleTo(0, automatedDistributionCenter);


            Assert.Throws <InvalidOperationException>(() => distributionCenter.SendVehicleTo(1, automatedDistributionCenter), "Doesnt throw exception when delivery location is full.");
        }
Beispiel #22
0
        public void TestWarehouseThrowsExceptionWhenDeliveryLocationIsfull()
        {
            var warehouse          = new Warehouse("SmartSolutions");
            var automatedWarehouse = new AutomatedWarehouse("SmartTech");

            warehouse.SendVehicleTo(0, automatedWarehouse);


            Assert.Throws <InvalidOperationException>(() => warehouse.SendVehicleTo(1, automatedWarehouse), "Doesnt throw exception when delivery location is full.");
        }
Beispiel #23
0
        public void SendVehicleToMethodThrowsExceptionForFullStorage()
        {
            Storage targetStorage = new AutomatedWarehouse("TargetStorage");
            Vehicle van           = new Van();
            var     method        = typeof(Storage).GetMethod("AddVehicle", BindingFlags.Instance | BindingFlags.NonPublic);

            method.Invoke(targetStorage, new object[] { van });

            Assert.Throws <InvalidOperationException>(() => storage.SendVehicleTo(0, targetStorage));
        }
        public void SendVehicleToShouldThrowExeptionOnFullStorage()
        {
            int garageSlot       = 1;
            var vehicle          = this.warehouse.GetVehicle(0);
            var deliveryLocation = new AutomatedWarehouse("Baumax");

            warehouse.SendVehicleTo(garageSlot, deliveryLocation);

            Assert.Throws <InvalidOperationException>(() => warehouse.SendVehicleTo(garageSlot, deliveryLocation));
        }
        public void SendVehcileToShouldWorkCorectly()
        {
            int index = 0;
            AutomatedWarehouse automatedWarehouse = new AutomatedWarehouse("Automated");
            int result = storage.SendVehicleTo(index, automatedWarehouse);

            Assert.AreEqual(result, 1, "The target place is not correct!");
            Assert.Throws <InvalidOperationException>(() => storage.GetVehicle(index), "Do not delete vehicle from source location!");

            Assert.AreEqual(automatedWarehouse.GetVehicle(result).GetType(), typeof(Semi), "The sent vehicle is not of the same type!");
        }
        public void SendVehicle_ShouldThrowException()
        {
            Storage tempStorage = new AutomatedWarehouse("Temp");

            for (int i = 1; i < tempStorage.Garage.Count; i++)
            {
                this.automatedWarehouse.SendVehicleTo(i % 1, tempStorage);
            }

            Assert.Throws <InvalidOperationException>(() => this.automatedWarehouse.SendVehicleTo(2, tempStorage), "No room in garage!");
        }
Beispiel #27
0
        public void SendVehicle_ShouldThrowExceptionForAutomatedWarehouseWhenNotEmptySlotsAvailableAtDestinationStorage()
        {
            this.storage = new AutomatedWarehouse("Test Automated Warehouse");

            var secondStorage = new AutomatedWarehouse("Second Automated Warehouse");
            var thirdStorage  = new AutomatedWarehouse("Third Automated Warehouse");

            secondStorage.SendVehicleTo(0, this.storage);

            Assert.Throws <InvalidOperationException>(() => thirdStorage.SendVehicleTo(0, this.storage));
        }
Beispiel #28
0
        public void ValidateGetVehicleMethod()
        {
            var garage = new AutomatedWarehouse("MyStorage");

            Assert.That(() => garage.GetVehicle(2),
                        Throws.InvalidOperationException.With.Message.EqualTo("Invalid garage slot!"));

            Assert.That(() => garage.GetVehicle(1),
                        Throws.InvalidOperationException.With.Message.EqualTo("No vehicle in this garage slot!"));

            Assert.That(garage.GetVehicle(0).GetType().Name, Is.EqualTo("Truck"));
        }
        public void SendVehicleToShouldThrowInvalidOperationExceptionWhenThereIsNoSpace()
        {
            AutomatedWarehouse automatedWarehouse = new AutomatedWarehouse("Automated");
            int index = 0;

            storage.SendVehicleTo(index, automatedWarehouse);

            Assert.That(() => storage.SendVehicleTo(1, automatedWarehouse), Throws
                        .InvalidOperationException
                        .With.Message.EqualTo("No room in garage!")
                        , "Do not throws exception when source storage is full!");
        }
Beispiel #30
0
        public void AutomatedWarehouseTest()
        {
            //-- Arrange
            AutomatedWarehouse AW1 = new AutomatedWarehouse("Brooklyn");

            string expected = "AW1 name is Brooklyn, has a capacity of 1, has 2 garageslots and contains 1 vehicles.";

            //-- Act
            string actual = AW1.Description;

            //-- Assert
            Assert.AreEqual(expected, actual);
        }