public void StandingSpotsPositiveTest() { Wagon wagon = new Wagon(1, 1, 1); Assert.AreEqual(1, wagon.StandingSpots); Wagon wagon2 = new Wagon(1, 1, 999999); Assert.AreEqual(999999, wagon2.StandingSpots); }
public void AddExistingWagonTest() { Administration admin = new Administration(); Wagon wagon = new Wagon(1, 20, 10); admin.Add(wagon); Assert.AreEqual(false, admin.Add(wagon)); }
public void WagonNumberPositiveTest() { Wagon wagon = new Wagon(1, 1, 1); Assert.AreEqual(1, wagon.WagonNumber); Wagon wagon2 = new Wagon(999999, 1, 1); Assert.AreEqual(999999, wagon2.WagonNumber); }
public void NumberOfSeatsPositiveTest() { Wagon wagon = new Wagon(1, 1, 1); Assert.AreEqual(1, wagon.Seats); Wagon wagon2 = new Wagon(1, 999999, 1); Assert.AreEqual(999999, wagon2.Seats); }
public void AddedWagonCanBeFoundTest() { Administration admin = new Administration(); Wagon wagon = new Wagon(1, 20, 10); admin.Add(wagon); Wagon foundWagon = admin.FindWagon(1); Assert.AreEqual(foundWagon, wagon); }
public void CalculateStandingSpotsTest() { Train train = new Train(1, 1); Wagon wagon1 = new Wagon(1, 25, 10); Wagon wagon2 = new Wagon(2, 15, 4); train.Add(wagon1); train.Add(wagon2); Assert.AreEqual(14, train.TotalStandingSpots); }
public void SetMaster(Wagon wagon) { if (wagon == null) { throw new ArgumentNullException("wagon"); } ExceptionIfNotInTrain(wagon); Master = wagon; }
public void unvalid_placing_two_differnt_diet_same_weight_one_wagon() { Herbivore herbivoor = new Herbivore(Weight.Medium); Carnivore carnivoor = new Carnivore(Weight.Medium); Wagon wagon = new Wagon(); wagon.PlaceAnimal(herbivoor); Assert.IsFalse(wagon.CanAnimalBePlaced(carnivoor)); }
public void Test_Placing_BIgherbivoor_BigCarnivoor_Same_wagon_Not_Allowed() { Herbivore herbivoor = new Herbivore(Weight.Large); Carnivore carnivoor = new Carnivore(Weight.Large); Wagon wagon = new Wagon(); wagon.PlaceAnimal(herbivoor); Assert.IsFalse(wagon.CanAnimalBePlaced(carnivoor)); }
public void TestMixAnimalPlacing() { Animal herbivoor = new Animal(5, Diet.Herbivore); Animal carnivoor = new Animal(5, Diet.Carnivore); Wagon wagon = new Wagon(); wagon.PlaceAnimal(herbivoor); Assert.IsFalse(wagon.CanAnimalBePlaced(carnivoor)); }
public void AsignAnimalsToWagon_Success() { AnimalList animalList = new AnimalList(); IWagon wagon = new Wagon(); wagon.AsignAnimalsToWagon(animalList.UnsortedAnimals); Assert.AreEqual(10, wagon.usedSpace); }
public void Down(Wagon wagon, IMerchandise merchandise) { if (this.IsOverweightPackage) { this.IsOverweightPackage = false; } wagon.Merchandise.RemoveAt(wagon.Merchandise.FindIndex(x => x.GetWeight() == merchandise.GetWeight())); }
public void PlaceAnimalInNewWagonNullTest() { //arrange Animal animal = null; Wagon wagon = new Wagon(Wagon.WagonSize.Regular); //assert/act Assert.ThrowsException <Exception>(() => wagon.PlaceAnimalInNewWagon(animal), "You need animal, buddy"); }
public void PlaceAnimalInNewWagonWrongWagonInput() { //arrange Animal animal = new Animal(Animal.AnimalType.Carnivore, Animal.AnimalSize.Medium); Wagon wagon = new Wagon(5); // act/assert Assert.ThrowsException <Exception>(() => wagon.PlaceAnimalInNewWagon(animal), "Big oof"); }
public void TryPlaceAnimalNullTest() { //arrange Wagon wagon = new Wagon(10); Animal animal = null; //act wagon.TryPlaceAnimal(animal); }
public void IsThereRoomForAnimal_ReturnsTrue_IfRoom_EmptyWagon() { Wagon wagon = new Wagon(); Animal animal = GenerateLargeCarnivore(); var result = wagon.IsThereRoomForAnimal(animal); Assert.IsTrue(result); }
public void AddAnimal_ReturnsTrue_IfNoOtherAnimalInWagon() { Wagon wagon = new Wagon(); Animal newAnimal = GenerateLargeHerbivore(); var result = wagon.AddAnimal(newAnimal); Assert.IsTrue(result); }
public void UnChargementAvecUnVolumeSupérieurAuVolumeRestant_DoitLeverUneException() { var wagon = new Wagon <Céréale>(Poids.Tonnes(20), Volume.M3(100)); wagon.Charger(new Avoine(), Volume.M3(50)); Assert.Throws <InvalidOperationException>(() => wagon.Charger(new Avoine(), Volume.M3(80))); }
private bool IsRelativeInverted(Wagon from, Wagon to) { if (from.Next == to && to.Next == from || from.Previous == to && to.Previous == from) { return(true); } return(false); }
public void UpdateWagon() { EmptyLists(); wagonRepository = new WagonRepository(context); Wagon wagon = new Wagon(1, "naam", 13, 25); Assert.True(wagonRepository.UpdateWagon(wagon)); }
public void WagonFit() { Wagon wagon = new Wagon(); Animal animal1 = new Animal(1, Diet.Carnivoor); Animal animal2 = new Animal(3, Diet.Herbivoor); wagon.CheckIfAnimalFits(animal1); Assert.IsTrue(wagon.CheckIfAnimalFits(animal2)); }
public void CreateWagon() { EmptyLists(); wagonRepository = new WagonRepository(context); Wagon wagon = new Wagon(4, "naam", 23, 45); Assert.Equal(4, wagonRepository.CreateWagon(wagon)); }
private void Serialize(Wagon wagon) { writer.Write(wagon.name); writer.Write(wagon.wheels.Length); for (int i = 0; i < wagon.wheels.Length; i++) { Serialize(wagon.wheels[i].Follower); } }
public void OverFillWagon() { Wagon wagon = FillWagonWithPlantenEters(); Dier plantKlein = new Dier(Dier.Groottes.Klein, false, "nvt"); bool shouldBeFalse = wagon.TryAddDier(plantKlein); Assert.AreEqual(false, shouldBeFalse); }
public void AddAnimalTest() { Wagon wagon = new Wagon(new Carnivore(Size.Medium)); Animal animal = new Herbivore(Size.Small); var result = wagon.AddAnimal(animal); Assert.IsFalse(result); }
private static Locomotive GetLocomotive(ConsistFile conFile, Folder folder, bool reverse) { Wagon wagon = reverse ? conFile.Train.Wagons.Where(w => w.IsEngine).LastOrDefault() : conFile.Train.Wagons.Where(w => w.IsEngine).FirstOrDefault(); if (null != wagon) { return(Locomotive.GetLocomotive(folder.ContentFolder.EngineFile(wagon.Folder, wagon.Name))); } return(null); }
public void GetWagonbyId() { EmptyLists(); wagonRepository = new WagonRepository(context); Wagon wagon = new Wagon(1, "naam", 13, 25); Assert.Equal(wagon.Id, wagonRepository.GetWagonbyId(1).Id); Assert.Equal(13, wagon.Stoelaantal_Klasse1); }
public void AddNoneToWagonTest() { //arrange Wagon wagon = new Wagon(10, false); //act int count = wagon.AnimalsInWagon.Count(); //assert Assert.AreEqual(0, count); }
public void BigCarnivoorbigHerbivoorInOneWagon() { Wagon wagon = new Wagon(); Animal animal1 = new Animal(5, Diet.Carnivoor); Animal animal2 = new Animal(5, Diet.Herbivoor); wagon.PlaceAnimal(animal1); Assert.IsFalse(wagon.CheckIfAnimalFits(animal2)); }
public void SmallCarnivoorBigHerbivoorInOneWagon() { Wagon wagon = new Wagon(); Animal animal1 = new Animal(1, Diet.Carnivoor); Animal animal2 = new Animal(5, Diet.Carnivoor); wagon.CheckIfAnimalFits(animal1); Assert.IsTrue(wagon.CheckIfAnimalFits(animal2)); }
public void TryPlaceAnimalWrongInput() { //arrange Wagon wagon = new Wagon(Wagon.WagonSize.Regular); Animal animal = new Animal(Animal.AnimalType.Carnivore, Animal.AnimalSize.Small); wagon.PlaceAnimalInNewWagon(animal); //act wagon.TryPlaceAnimal(animal); }
public void ToStringWithMultipleWagonsTest() { Train train = new Train(1, 1); Wagon wagon1 = new Wagon(1, 1, 1); Wagon wagon2 = new Wagon(2, 1, 1); Wagon wagon3 = new Wagon(3, 1, 1); Wagon wagon4 = new Wagon(4, 1, 1); train.Add(wagon1); train.Add(wagon2); train.Add(wagon3); train.Add(wagon4); Assert.AreEqual("1 - 2 - 3 - 4", train.ToString()); }
/// <summary> /// Добавление вагона к поезду /// </summary> /// <param name="trainId"></param> /// <param name="wagonType"></param> public static async Task AddWagonToTrain(int trainId, WagonType wagonType) { var wagon = new Wagon(); wagon.WagonType = (byte)wagonType; wagon.WagonNum = GetWagonNumber(trainId); ContextKeeper.Wagons.Add(wagon); var trainWagon = new TrainWagon(); trainWagon.WagonId = wagon.Id; trainWagon.TrainId = trainId; ContextKeeper.TrainWagons.Add(trainWagon); await Task.Run(() => AddSeatsToWagonAsync(wagon.Id, wagonType)); }
public double GetPrice(Wagon wagon, int? startingStationId, int? lastStationId) { double price = (wagon.Route.FullPrice); double q1 = 1; double q2 = 1; double answer = 1; if (startingStationId != 0 && lastStationId != 0) { if (wagon.Route.WayStations.Any(s => s.Station.Id == lastStationId) && wagon.Route.WayStations.Any(s => s.Station.Id == startingStationId)) { q1 = (wagon.Route.WayStations.First(s => s.Station.Id == lastStationId).ArrivalDateTime.Ticks) - (wagon.Route.WayStations.First(s => s.Station.Id == lastStationId).ArrivalDateTime.Ticks); q2 = (wagon.Route.ArrivalDateTime - wagon.Route.DepatureDateTime).Ticks; } } answer = price * q1 / q2 * wagon.WagonType.Coefficient; return answer; }
public void WagonNumberZeroTest() { Wagon wagon = new Wagon(0, 1, 1); }
public void AddWagonWhenNullTest() { Wagon wagon = new Wagon(1, 1, 1); wagon.AddWagonTo(null); }
private void btnAddWagons_Click(object sender, EventArgs e) { int wagonNumber; int numberOfSeats; int numberOfStandingSpots; Wagon wagon = null; if (!int.TryParse(txtBoxWagonNumber.Text, out wagonNumber) || !int.TryParse(txtBoxSeats.Text, out numberOfSeats) || !int.TryParse(txtBoxStandingSpots.Text, out numberOfStandingSpots)) { MessageBox.Show("Invalid input. Please only enter numbers"); } else { wagon = new Wagon(wagonNumber, numberOfSeats, numberOfStandingSpots); Wagon check = administration.FindWagon(wagon.WagonNumber); //find wagon if it already exists if (check == null && wagon != null && administration.Add(wagon)) //add wagon { updateListViewWagons(); } else { MessageBox.Show("Something went wrong. Could not add Wagon"); } } }
//check if wagon is in use public bool WagonInUse(Wagon wagon) { foreach (Train t in administration.Trains) { foreach (Wagon w in t.Wagons) { if (wagon.WagonNumber == w.WagonNumber) { return true; } } } return false; }
//add wagon public bool Add(Wagon wagon) { if (wagon == null) { throw new ArgumentNullException("wagon"); } Wagon w = FindWagon(wagon.WagonNumber); if (w == null) { Wagons.Add(wagon); //add to list if (OnWagonUpdate != null) { OnWagonUpdate(this, wagon, true); } return true; } return false; }
// remove wagon public bool Remove(Wagon wagon) { if (wagon == null) { throw new ArgumentNullException("wagon"); } Wagon w = FindWagon(wagon.WagonNumber); if (w != null) { Wagons.Remove(w); //remove from list if (OnWagonUpdate != null) { OnWagonUpdate(this, w, false); } return true; } return false; }
public void NumberOfSeatsZeroTest() { Wagon wagon = new Wagon(0, 1, 1); }
public void StandingSpotsNegativeTest() { Wagon wagon = new Wagon(1, 1, -1); Wagon wagon2 = new Wagon(1, 1, -999999); }
public void FindWagonTest() { Administration admin = new Administration(); Wagon wagon1 = new Wagon(1, 1, 1); Wagon wagon2 = new Wagon(2, 1, 1); Wagon wagon3 = new Wagon(3, 1, 1); admin.Add(wagon1); admin.Add(wagon2); admin.Add(wagon3); Assert.AreEqual(wagon3, admin.FindWagon(3)); Assert.AreEqual(wagon2, admin.FindWagon(2)); Assert.AreEqual(wagon1, admin.FindWagon(1)); }
public void RemoveNotExistinWagonTest() { Administration admin = new Administration(); Wagon wagon = new Wagon(1, 1, 1); Assert.AreEqual(false, admin.Remove(wagon)); }
public void ToStringWithOneWagonTest() { Train train = new Train(1, 1); Wagon wagon = new Wagon(1, 1, 1); train.Add(wagon); Assert.AreEqual("1", train.ToString()); }
public void RemoveWagonTest() { Administration admin = new Administration(); Wagon wagon1 = new Wagon(1, 1, 1); Wagon wagon2 = new Wagon(2, 1, 1); Wagon wagon3 = new Wagon(3, 1, 1); admin.Add(wagon1); admin.Add(wagon2); admin.Add(wagon3); Assert.AreEqual(true, admin.Remove(wagon3)); Assert.AreEqual(true, admin.Remove(wagon2)); Assert.AreEqual(true, admin.Remove(wagon1)); }
public void StandingSpotsZeroTest() { Wagon wagon = new Wagon(1, 1, 0); }
public void WagonNumberNegativeTest() { Wagon wagon = new Wagon(-1, 1, 1); Wagon wagon2 = new Wagon(-999999, 1, 1); }
public ActionResult AddWagons(WagonAddViewModel wagonAddViewModel) { if (!ModelState.IsValid) { wagonAddViewModel.WagonTypeListItems = _wagonTypeLogic.GetWagonTypeListItems(); return View(wagonAddViewModel); } Route route = _routeLogic.GetRouteById(wagonAddViewModel.RouteId); WagonType wagonType = _wagonTypeLogic.GetWagonTypeById(wagonAddViewModel.WagonType); for (int i = 0; i < wagonAddViewModel.NumberOfWagons; i++) { Wagon wagon = new Wagon { Number = i + 1, WagonType = wagonType, Tickets = new List<Ticket>() }; route.Wagons.Add(wagon); } _routeLogic.EditRoute(route); return RedirectToAction("Index"); }
public void AddNewWagonTest() { Administration admin = new Administration(); Wagon wagon = new Wagon(1,20,10); Assert.AreEqual(true, admin.Add(wagon)); }
public void NumberOfSeatsNegativeTest() { Wagon wagon = new Wagon(-1, 1, 1); Wagon wagon2 = new Wagon(-999999, 1, 1); }