public void addChildToThingThrowsException() { Thing thing = new Thing("lantern"); var testDel = new TestDelegate(() => thing.AddChild(new Thing("fork"))); Assert.That(testDel, Throws.TypeOf<NoChildrenForThingsException>()); }
public void getChildrenOfThingReturnsNull() { Thing thing = new Thing("lantern"); var children = thing.GetChildren(); Assert.That(children, Is.Null); }
public void personCarriesThingReturnsCarriedThing() { Person person = new Person("John"); Thing thing = new Thing("Hat"); var item = person.CarryItem(thing); Assert.That(item, Is.EqualTo(thing)); }
public void containerHasChildrenReturnsTrueIfChildren() { Container container = new Container("chest"); var entity = new Thing("cup"); var item = container.AddChild(entity); Assert.That(container.HasChildren(), Is.True); }
public void supporterHasChildrenReturnsTrueIfChildren() { Supporter supporter = new Supporter("table"); var entity = new Thing("cup"); var item = supporter.AddChild(entity); Assert.That(supporter.HasChildren(), Is.True); }
public void containerAddChildReturnsChild() { Container container = new Container("chest"); var entity = new Thing("cup"); var item = container.AddChild(entity); Assert.That(item.SameIdentityAs(entity), Is.True); }
public void supporterAddChildReturnsChild() { Supporter supporter = new Supporter("table"); var entity = new Thing("cup"); var item = supporter.AddChild(entity); Assert.That(item.SameIdentityAs(entity), Is.True); }
public void supporterGetChildrenReturnsChildren() { Supporter supporter = new Supporter("table"); var entity = new Thing("cup"); var item = supporter.AddChild(entity); var children = supporter.GetChildren(); Assert.That(children.First().SameIdentityAs(item), Is.True); }
public void containerGetChildrenReturnsChildren() { Container container = new Container("chest"); var entity = new Thing("cup"); var item = container.AddChild(entity); var children = container.GetChildren(); Assert.That(children.First().SameIdentityAs(item), Is.True); }
public void personWearsItemItIsWorn() { Person person = new Person("John"); Thing thing = new Thing("Hat"); person.WearItem(thing); var clothes = person.GetClothing(); Assert.That(clothes.First().SameIdentityAs(thing)); }
public void addNullPartReturnsNull() { Thing thing = new Thing("hat"); var thing2 = thing.AddPart(null); Assert.That(thing2, Is.Null); }
public void addPartOfReturnsTheAddedPart() { Thing thing = new Thing("hat"); var thing2 = thing.AddPart(new Thing("hatband")); Assert.That(thing.HasParts,Is.True); }
public void addPartOfReturnsHasPartTrue() { Thing thing = new Thing("hat"); thing.AddPart(new Thing("hatband")); Assert.That(thing.HasParts,Is.True); }
public void thingCanNotWearItems() { Thing thing = new Thing("hat"); var testDel = new TestDelegate(() => thing.WearItem(new Thing("hatband"))); Assert.That(testDel, Throws.TypeOf<CanNotWearItemsException>()); }
public List<IEntity> Parse(string objectString) { ObjectText = objectString; Objects = new List<IEntity>(); if (objectString == string.Empty) { return Objects; } string[] objectArray = objectString.Split(new string[] { Settings.ObjectDelimiter}, StringSplitOptions.RemoveEmptyEntries); foreach (var s in objectArray) { var attributes = getObjectAttributes(s); var sName = attributes != string.Empty ? s.Replace(attributes, string.Empty) : s; IEntity entity = null; if (attributes != string.Empty) { attributes = attributes.Replace("[", string.Empty).Replace("]", string.Empty); if (attributes.IndexOfAny("mM".ToCharArray()) != -1) { entity = new Person(sName); ((Person)entity).Gender = Gender.Male; } if (attributes.IndexOfAny("fF".ToCharArray()) != -1) { if (entity != null && entity.IsPerson()) throw new PersonCannotBeTwoGenders(); entity = new Person(sName); ((Person)entity).Gender = Gender.Female; } if (attributes.IndexOfAny("pP".ToCharArray()) != -1) { if (entity != null && entity.IsPerson()) throw new PersonCannotBeTwoGenders(); entity = new Person(sName); ((Person)entity).Gender = Gender.Neutral; } if (attributes.IndexOfAny("cC".ToCharArray()) != -1) { if (entity != null && entity.IsPerson()) throw new PersonCannotBeContainer(); entity = new Container(sName); } if (attributes.IndexOfAny("uU".ToCharArray()) != -1) { if (entity != null && entity.IsPerson()) throw new PersonCannotBeSupporter(); entity = new Supporter(sName); } if (attributes.IndexOfAny("sS".ToCharArray()) != -1) { if (entity != null && entity.IsPerson()) { throw new PersonCannotBeScenery(); } entity = new Thing(sName) {Scenery = true}; } } else { entity = new Thing(sName); } Objects.Add(entity); } return Objects; }
public void getPartsReturnsPartsofThing() { Thing thing = new Thing("hat"); var thing2 = thing.AddPart(new Thing("hatband")); Assert.That(thing.GetParts().First().SameIdentityAs(thing2), Is.True); }
public void hasChildrenOnReturnsFalseOnEmptyThing() { Thing thing = new Thing("Lantern"); Assert.That(thing.HasChildren, Is.False); }
public void createEmptyThingReturnsAUniqueThing() { Thing thing = new Thing("book"); Assert.That(thing.SameIdentityAs(new Thing("book")), Is.True); }
public void testThingIsNotContainerType() { Thing thing = new Thing("lantern"); Assert.That(thing.IsContainer, Is.False); }
public void testThingIsNotSupporterType() { Thing thing = new Thing("lantern"); Assert.That(thing.IsSupporter, Is.False); }
public void testThingIsNotPersonType() { Thing thing = new Thing("lantern"); Assert.That(thing.IsPerson, Is.False); }
public void thingIsWorn() { Person person = new Person("Jason"); Thing thing = new Thing("hat"); person.WearItem(thing); Assert.That(thing.IsWorn, Is.True); }
public void testThingIsThingType() { Thing thing = new Thing("lantern"); Assert.That(thing.IsThing, Is.True); }
public void thingIsPartOf() { Thing thing = new Thing("hat"); var thing2 = new Thing("hatband"); thing.AddPart(thing2); Assert.That(thing2.IsPartOf, Is.True); }