Пример #1
0
		public readonly List<Item> items = new List<Item>();//Invariant: contents not null.
		public static Inventory MakeExample () {
			var inventory = new Inventory();
			inventory.items.Add(new Item {Name = "Bat", Description = "A sturdy wooden bat.", Price = 105});
			inventory.items.Add(new Item {Name = "Ball", Description = "A white ball bound in red thread. Costs 100 less than the bat and in total they cost 110. How much does it cost?", Price = 5});
			inventory.items.Add(new Item {Name = "Mona Lisa", Description = "Some people think it's pretty or something?", Price = 787000000/*If we're pretending "1" == 1 cent, this is actually 100x too cheap, but 32-bit ints.*/});
			return inventory;
		}
			[Theory] public static void Invariants (Inventory inventory) {
				Assume.That(inventory != null);
				// ReSharper disable once PossibleNullReferenceException
				inventory.AssertInvariants();
			}
			[Test] public void StockTest () {
				var inventory = new Inventory();
				Assert.AreEqual(0, inventory.StockOfItemsNamed("a"));
				inventory.items.Add(new Item {Name = "a"});
			}