public void StackAddStack() { ResourceStack stack1 = new ResourceStack(ResourceElement.ResourceType.Water); ResourceElement elem1 = new ResourceElement(ResourceElement.ResourceType.Water, station, 100, 1); ResourceElement elem2 = new ResourceElement(ResourceElement.ResourceType.Water, station, 50, 2); stack1.Add(elem1); stack1.Add(elem2); ResourceStack stack2 = new ResourceStack(ResourceElement.ResourceType.Water); ResourceElement elem3 = new ResourceElement(ResourceElement.ResourceType.Water, station, 25, 3); stack2.Add(elem3); stack1.Add(stack2); Assert.AreEqual(175, stack1.Qte); Assert.AreEqual(0, stack2.Qte); ResourceElement elem4 = new ResourceElement(ResourceElement.ResourceType.ToxicWaste, station, 1, 1); ResourceStack stack3 = new ResourceStack(elem4); stack1.Add(stack3); Assert.AreEqual(175, stack1.Qte); Assert.AreEqual(1, stack3.Qte); }
public void StackAdd() { ResourceStack stack = new ResourceStack(ResourceElement.ResourceType.Wastes); ResourceElement elem1 = new ResourceElement(ResourceElement.ResourceType.Wastes, station, 100, 200); stack.Add(elem1); Assert.AreEqual(100, stack.Qte); Assert.AreEqual(ResourceElement.ResourceType.Wastes, stack.Type); Assert.AreEqual(0, elem1.Quantity); ResourceElement elem2 = new ResourceElement(ResourceElement.ResourceType.Water, station, 50, 201); stack.Add(elem2); Assert.AreEqual(100, stack.Qte); Assert.AreEqual(ResourceElement.ResourceType.Wastes, stack.Type); Assert.AreEqual(50, elem2.Quantity); ResourceElement elem3 = new ResourceElement(ResourceElement.ResourceType.Wastes, station, 200, 300); stack.Add(elem3); Assert.AreEqual(300, stack.Qte); Assert.AreEqual(ResourceElement.ResourceType.Wastes, stack.Type); Assert.AreEqual(0, elem3.Quantity); }
public void StackAddStackRandom() { System.Random _rand = new System.Random(); for (int i = 0; i < 50000; i++) // Faire 50.000 tests aléatoires { int quantityElem1 = _rand.Next(0, int.MaxValue / 4); int quantityElem2 = _rand.Next(0, int.MaxValue / 4); int quantityElem3 = _rand.Next(0, int.MaxValue / 4); ResourceStack stack1 = new ResourceStack(ResourceElement.ResourceType.Water); ResourceElement elem1 = new ResourceElement(ResourceElement.ResourceType.Water, station, quantityElem1, 1); ResourceElement elem2 = new ResourceElement(ResourceElement.ResourceType.Water, station, quantityElem2, 2); stack1.Add(elem1); stack1.Add(elem2); ResourceStack stack2 = new ResourceStack(ResourceElement.ResourceType.Water); ResourceElement elem3 = new ResourceElement(ResourceElement.ResourceType.Water, station, quantityElem3, 3); stack2.Add(elem3); stack1.Add(stack2); Assert.AreEqual(quantityElem1 + quantityElem2 + quantityElem3, stack1.Qte); Assert.AreEqual(0, stack2.Qte); ResourceElement elem4 = new ResourceElement(ResourceElement.ResourceType.ToxicWaste, station, 10, 1); ResourceStack stack3 = new ResourceStack(elem4); stack1.Add(stack3); Assert.AreEqual(quantityElem1 + quantityElem2 + quantityElem3, stack1.Qte); Assert.AreEqual(10, stack3.Qte); } }
public void StackSubStack() { ResourceElement elem1 = new ResourceElement(ResourceElement.ResourceType.Water, station, 100, 1); ResourceStack stack = new ResourceStack(elem1); ResourceElement elem2 = new ResourceElement(ResourceElement.ResourceType.Water, station, 100, 2); stack.Add(elem2); ResourceStack s1 = stack.GetSubStack(25); Assert.AreEqual(25, s1.Qte); Assert.AreEqual(ResourceElement.ResourceType.Water, s1.Type); Assert.AreEqual(175, stack.Qte); Assert.AreEqual(ResourceElement.ResourceType.Water, stack.Type); foreach (ResourceElement e in s1.GetElements()) { Assert.AreEqual(1, e.DateProd); } ResourceStack s2 = stack.GetSubStack(200); Assert.AreEqual(null, s2); Assert.AreEqual(175, stack.Qte); //retirer un stack composé de 2 elements ResourceStack s3 = stack.GetSubStack(100); Assert.AreEqual(100, s3.Qte); Assert.AreEqual(ResourceElement.ResourceType.Water, s3.Type); Assert.AreEqual(75, stack.Qte); List <ResourceElement> elemsStack = stack.GetElements(); Assert.AreEqual(1, elemsStack.Count); Assert.AreEqual(2, elemsStack[0].DateProd); List <ResourceElement> elems = s3.GetElements(); Assert.AreEqual(2, elems.Count); Assert.AreEqual(1, elems[0].DateProd); Assert.AreEqual(75, elems[0].Quantity); Assert.AreEqual(2, elems[1].DateProd); Assert.AreEqual(25, elems[1].Quantity); }
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 AddResources(ResourceStack _ajout) { ressources.Add(_ajout); SetImage(); }
public void AddRessource(ResourceStack _ajout) { stockCurrent.Add(_ajout); }