public void Residential_Scavenge() { for (int i = 0; i < 1000; i++) { items = new List <Item>(); for (int j = 1; j < 21; j++) { Item tmp = new Item(StringMaker.makeItemStr(j)); items.Add(tmp); } res = new Residential(1, rnd.Next(1, 10), rnd.Next(1, 10)); var ids = new List <int>(); var found = res.Scavenge(items); Assert.IsTrue(res.GetScavenged(), "Should be scavenged"); Assert.IsTrue(res.GetMaxItems() >= found.Count, "Items found should not exceed max"); Assert.IsTrue(found.Count > 0, "Should be at least one item"); foreach (Item item in found) { Assert.IsFalse(ids.Contains(item.GetID()), "ID should not be in the list already"); ids.Add(item.GetID()); Assert.IsTrue(res.GetMaxAmount() >= item.GetAmount(), "Items found should not have more instances max"); } found = res.Scavenge(items); Assert.IsTrue(found.Count == 0, "Should be no items in list"); } }
public void Residential_StandardConstructor() { Assert.IsFalse(res.GetScavenged(), "Should not be scavenged"); Assert.AreEqual(1, res.GetSublocationID(), "ID should be 1"); Assert.AreEqual(3, res.GetMaxItems(), "Max items should be 3"); Assert.AreEqual(5, res.GetMaxAmount(), "Max amount should be 5"); }
public void Location_RandomFullConstructor() { for (int j = 0; j < 100; j++) { int testSize = rnd.Next(1, 10000); int maxItems = rnd.Next(1, 10000); int maxAmount = rnd.Next(1, 10000); l.GenerateSubLocations(testSize, maxItems, maxAmount); Sublocation last = new Residential(); Assert.IsFalse(l.GetVisited(), "New Location should not be visited"); Assert.IsTrue(l.IsCurrentSublocationNull(), "Current sublocation should be null"); Assert.AreEqual(null, l.GetCurrentSubLocation(), "Current Sublocation should be null"); Assert.AreEqual(testSize, l.GetSize(), "Size should be " + testSize); for (int i = 1; i < testSize + 1; i++) { Assert.IsTrue(l.SetCurrentSubLocation(i), "Setting to an id which exists (" + i + ") should be succesful"); Assert.IsFalse(l.IsCurrentSublocationNull(), "Current sublocation should not be null"); last = l.GetCurrentSubLocation(); Assert.AreEqual(i, last.GetSublocationID(), "IDs should match"); Assert.AreEqual(maxItems, last.GetMaxItems(), "Max items should match"); Assert.AreEqual(maxAmount, last.GetMaxAmount(), "Max amount should match"); } Assert.IsFalse(l.SetCurrentSubLocation(testSize + 1), "Setting to an id which does not exists (" + (testSize + 1) + ") should be unsuccesful"); Assert.IsFalse(l.IsCurrentSublocationNull(), "Current sublocation should not be null"); Assert.AreEqual(last, l.GetCurrentSubLocation(), "Current Sublocation should have remained the same"); } }