public void CheckIfLoadVehicleWorksCorrectly() { Storagemaster storageMaster = new Storagemaster(); storageMaster.RegisterStorage("Warehouse", "storage"); storageMaster.SelectVehicle("storage", 1); storageMaster.AddProduct("Gpu", 12); storageMaster.AddProduct("HardDrive", 120); List <string> productsToLoad = new List <string>() { "Gpu", "HardDrive" }; storageMaster.LoadVehicle(productsToLoad); FieldInfo vehicleField = typeof(Storagemaster) .GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .First(f => f.Name == CurrentVehicleName); Vehicle vehicle = (Vehicle)vehicleField.GetValue(storageMaster); Assert.AreEqual(2, vehicle.Trunk.Count); }
public void CheckIfAddsCorrectly() { Storagemaster storageMaster = new Storagemaster(); var field = typeof(Storagemaster) .GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .First(f => f.Name == ProductsPoolName); Product product = (Product)Activator.CreateInstance(typeof(Ram), new object[] { 13.5 }); storageMaster.AddProduct("Ram", 13.5); Dictionary <string, Stack <Product> > pool = (Dictionary <string, Stack <Product> >)field.GetValue(storageMaster); Assert.That(pool["Ram"].Any(x => x.Price == 13.5)); }