public void TestDistributionCenterUnloadProductThrowsExceptionWhenStorageIsfull()
        {
            var distributionCenter = new DistributionCenter("SmartSolutions");
            var hardDirve          = new HardDrive(123);

            distributionCenter.GetVehicle(0).LoadProduct(hardDirve);
            distributionCenter.GetVehicle(0).LoadProduct(hardDirve);
            distributionCenter.UnloadVehicle(0);
            distributionCenter.GetVehicle(0).LoadProduct(hardDirve);
            Assert.Throws <InvalidOperationException>(() => distributionCenter.UnloadVehicle(0), "Doesnt Throw Exception when storage house if full.");
        }
        public void TestDistributionCenterProperyProductsReturnsTheCorrectElements()
        {
            var distributionCenter = new DistributionCenter("SmartSolutions");
            var hardDirve          = new HardDrive(123);

            distributionCenter.GetVehicle(0).LoadProduct(hardDirve);
            distributionCenter.UnloadVehicle(0);
            Assert.AreEqual(distributionCenter.Products.ElementAt(0), hardDirve, "Product is not the same as expected.");
        }
        public void TestDistributionCenterPropertyIsFullReturnsFalse()
        {
            var distributionCenter = new DistributionCenter("SmartSolutions");
            var hardDirve          = new HardDrive(123);

            distributionCenter.GetVehicle(0).LoadProduct(hardDirve);
            distributionCenter.UnloadVehicle(0);
            Assert.IsFalse(distributionCenter.IsFull, "DistributionCenter should not be full.");
        }
        public void TestDistributionCenterUnloadProductReturnsTheCorrectNumberOfUnloadedProducts()
        {
            var distributionCenter = new DistributionCenter("SmartSolutions");
            var hardDirve          = new HardDrive(123);

            distributionCenter.GetVehicle(0).LoadProduct(hardDirve);
            distributionCenter.GetVehicle(0).LoadProduct(hardDirve);

            Assert.AreEqual(distributionCenter.UnloadVehicle(0), 2, "Doesnt unload the correct number of products");
        }
Exemple #5
0
        public void ValidateUnloadVehicleMethod()
        {
            var storage = new DistributionCenter("MyStorage");
            var vehicle = new Van();
            var product = new HardDrive(1.1);

            vehicle.LoadProduct(product);
            vehicle.LoadProduct(product);

            var garage = (Vehicle[])this.GetType("Storage")
                         .GetField("garage", BindingFlags.NonPublic | BindingFlags.Instance)
                         .GetValue(storage);

            garage[1] = vehicle;

            Assert.That(storage.UnloadVehicle(1), Is.EqualTo(2));

            var products = (List <Product>) this.GetType("Storage")
                           .GetField("products", BindingFlags.NonPublic | BindingFlags.Instance)
                           .GetValue(storage);

            Assert.That(products.Count, Is.EqualTo(2));
        }
Exemple #6
0
        public void TestUnloadVehicle()
        {
            Storage storage = new DistributionCenter("Pesho");

            Assert.AreEqual(0, storage.UnloadVehicle(1));
        }