public void StandingTest1() { Universe universe = new Universe(0); Station s = universe.GetStation(1); Corporation corp = universe.CreateCorp(1); Ship ship = s.CreateShip(corp); ShipDestination dest = ship.AddDestination(s); dest.AddLoad(ResourceElement.ResourceType.Wastes, 1000); ship.Start(); Hangar corpHangar = s.CreateHangar(corp); ResourceElement elem = new ResourceElement(ResourceElement.ResourceType.Wastes, s, 2000, 1); ResourceStack stack = new ResourceStack(elem); corpHangar.Add(stack); Assert.IsTrue(s.Type == Station.StationType.City); Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Water, 1) - Station.defaultStanding) < 0.0001); Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Wastes, 1) - Station.defaultStanding) < 0.0001); //simuler une augmentation de standing for (int i = 0; i < 10; i++) { universe.Update(); } //apres 2 jours de chargement... // day1 : 0.0 + (1 * 0.05) = 0.05 // day2 : 0.05 + ((1-0.05) * 0.05) = 0.0975 Assert.IsTrue(System.Math.Abs(s.GetStanding(ResourceElement.ResourceType.Wastes, 1) - 0.0975) < 0.0001); }
public void ShipUnloadingSelling() { Universe u = new Universe(0); Station city = u.GetStation(1); Station city2 = u.GetStation(2); Corporation player = u.CreateCorp(1); Ship ship = city.CreateShip(player); ResourceElement e = new ResourceElement(ResourceElement.ResourceType.Food, city2, 100, 1); ResourceStack stack = new ResourceStack(e); ship.Cargo.Add(stack); Hangar h = city.CreateHangar(player); ShipDestination dest = ship.AddDestination(city); dest.AddUnload(ResourceElement.ResourceType.Food, 100); ship.Start(); //ca prend 10 fois pour decharger for (int i = 0; i < 11; i++) { u.Update(); } Assert.AreEqual(0, ship.Cargo.GetResourceQte(ResourceElement.ResourceType.Food)); Assert.AreEqual(15000, ship.Owner.ICU); Assert.AreEqual(100, city.GetHangar(-1).GetResourceQte(ResourceElement.ResourceType.Food)); }
public void ShipLoading1() { Universe u = new Universe(0); Station s = u.GetStation(1); Station s2 = u.GetStation(2); Corporation corp = u.CreateCorp(1); Ship ship = s.CreateShip(corp); Hangar h = s.CreateHangar(corp); ResourceElement e = new ResourceElement(ResourceElement.ResourceType.Wastes, s, 100, 1); h.Add(new ResourceStack(e)); s.CreateHangar(corp); ShipDestination dest = ship.AddDestination(s); dest.AddLoad(ResourceElement.ResourceType.Wastes, 100); ShipDestination dest2 = ship.AddDestination(s2); ship.Start(); for (int ite = 0; ite < 10; ite++) { u.Update(); } Assert.AreEqual(100, ship.Cargo.GetResourceQte(ResourceElement.ResourceType.Wastes)); u.Update(); //chargerment u.Update(); //sortie Assert.IsNull(ship.CurrentStation); }
public void ShipMoving1() { Universe u = new Universe(0); Station s = u.GetStation(1); Station s2 = u.GetStation(2); Corporation corp = u.CreateCorp(1); Ship ship = s.CreateShip(corp); ShipDestination dest = ship.AddDestination(s2); ShipDestination dest2 = ship.AddDestination(s); ship.Start(); Assert.NotNull(ship.CurrentStation); Assert.AreEqual(s.ID, ship.CurrentStation.ID); u.Update();//on devrait sortir Assert.IsNull(ship.CurrentStation); for (int ite = 0; ite < 9; ite++) //station suivante { u.Update(); } Assert.NotNull(ship.CurrentStation); Assert.AreEqual(s2.ID, ship.CurrentStation.ID); for (int ite = 0; ite < 11; ite++) //sortir + station suivante { u.Update(); } Assert.NotNull(ship.CurrentStation); Assert.AreEqual(s.ID, ship.CurrentStation.ID); }
public void ShipDestinationRemoveUsed() { Station s = u.GetStation(1); Ship ship = s.CreateShip(corp); ShipDestination dest1 = ship.AddDestination(u.GetStation(10)); ShipDestination dest2 = ship.AddDestination(u.GetStation(15)); ship.Start(); ship.RemoveDestination(dest1); Assert.AreEqual(2, ship.GetDestinations().Count); }
public void ShipDestinationRemoveDouble() { Station s = u.GetStation(1); Ship ship = s.CreateShip(corp); ShipDestination dest1 = ship.AddDestination(u.GetStation(10)); ShipDestination dest2 = ship.AddDestination(u.GetStation(20)); ShipDestination dest3 = ship.AddDestination(u.GetStation(10)); ShipDestination dest4 = ship.AddDestination(u.GetStation(20)); ship.RemoveDestination(dest1); Assert.AreEqual(3, ship.GetDestinations().Count); }
public void ShipDestinationRemoveWrong() { Station s = u.GetStation(1); Ship s1 = s.CreateShip(corp); Ship s2 = s.CreateShip(corp); ShipDestination dest1 = s1.AddDestination(u.GetStation(10)); ShipDestination dest2 = s1.AddDestination(u.GetStation(20)); ShipDestination dest3 = s2.AddDestination(u.GetStation(10)); ShipDestination dest4 = s2.AddDestination(u.GetStation(20)); s2.RemoveDestination(dest1); Assert.AreEqual(2, s2.GetDestinations().Count); }
public void ShipDestinationRemovePriorToCurrent() { Station s = u.GetStation(1); Ship ship = s.CreateShip(corp); ShipDestination d1 = ship.AddDestination(u.GetStation(10)); ShipDestination d2 = ship.AddDestination(s); ship.Start(); for (int i = 0; i < 12; i++) { u.Update(); } Assert.AreEqual(d2, ship.CurrentDestination); ship.RemoveDestination(d1); Assert.AreEqual(d2, ship.CurrentDestination); }
public void ShipDestinationRemoveSimple() { Station s = u.GetStation(1); Ship ship = s.CreateShip(corp); bool eventDone = false; ship.onDestinationChange += () => { eventDone = true; }; ShipDestination dest1 = ship.AddDestination(u.GetStation(10)); ShipDestination dest2 = ship.AddDestination(u.GetStation(20)); Assert.IsTrue(eventDone); eventDone = false; ship.RemoveDestination(dest1); Assert.IsTrue(eventDone); Assert.AreEqual(1, ship.GetDestinations().Count); Assert.AreEqual(dest2, ship.GetDestinations()[0]); }
public void ShipDestinationCreation() { Station s = u.GetStation(1); Ship ship = s.CreateShip(corp); ShipDestination dest = ship.AddDestination(s); Assert.NotNull(dest); Assert.AreEqual(s.ID, dest.Destination.ID); dest.AddLoad(ResourceElement.ResourceType.Wastes, 100); dest.AddUnload(ResourceElement.ResourceType.Water, 200); Assert.AreEqual(1, dest.GetLoads().Count); Assert.AreEqual(ResourceElement.ResourceType.Wastes, dest.GetLoads()[0].type); Assert.AreEqual(100, dest.GetLoads()[0].qte); Assert.AreEqual(1, dest.GetUnloads().Count); Assert.AreEqual(ResourceElement.ResourceType.Water, dest.GetUnloads()[0].type); Assert.AreEqual(200, dest.GetUnloads()[0].qte); }