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 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 HangarTransactions1() { Hangar h = new Hangar(station, corporation); ResourceElement elem1 = new ResourceElement(ResourceElement.ResourceType.Wastes, station, 100, 1); ResourceStack stack1 = new ResourceStack(elem1); h.Add(stack1); Assert.AreEqual(100, h.GetResourceQte(ResourceElement.ResourceType.Wastes)); Assert.AreEqual(0, stack1.Qte); ResourceElement elem2 = new ResourceElement(ResourceElement.ResourceType.ToxicWaste, station, 50, 2); ResourceStack stack2 = new ResourceStack(elem2); h.Add(stack2); Assert.AreEqual(100, h.GetResourceQte(ResourceElement.ResourceType.Wastes)); Assert.AreEqual(0, stack1.Qte); Assert.AreEqual(50, h.GetResourceQte(ResourceElement.ResourceType.ToxicWaste)); Assert.AreEqual(0, stack2.Qte); }
public void HangarRemoveResources() { Hangar h = new Hangar(station, corporation); ResourceElement elem1 = new ResourceElement(ResourceElement.ResourceType.Wastes, station, 100, 1); ResourceStack stack1 = new ResourceStack(elem1); h.Add(stack1); ResourceElement elem2 = new ResourceElement(ResourceElement.ResourceType.Wastes, station, 100, 2); ResourceElement elem3 = new ResourceElement(ResourceElement.ResourceType.Wastes, station, 100, 3); ResourceStack stack2 = new ResourceStack(elem2); stack2.Add(elem3); h.Add(stack2); ResourceStack outStack = h.GetStack(ResourceElement.ResourceType.Wastes, 50); Assert.NotNull(outStack); Assert.AreEqual(50, outStack.Qte); Assert.AreEqual(ResourceElement.ResourceType.Wastes, outStack.Type); Assert.AreEqual(250, h.GetResourceQte(ResourceElement.ResourceType.Wastes)); }
public void HangarStackRemove() { Hangar h = new Hangar(station, corporation); ResourceElement elem1 = new ResourceElement(ResourceElement.ResourceType.Wastes, station, 100, 1); ResourceStack stack1 = new ResourceStack(elem1); bool eventTrigered = false; h.Add(stack1); h.onRemoveStack += (s) => { eventTrigered = true; }; h.GetStack(ResourceElement.ResourceType.Wastes, 100); Assert.IsTrue(eventTrigered); Assert.AreEqual(0, h.ResourceStacks.Count); }