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); }