public void supporterAddNullChildReturnsNull()
    {
      Supporter supporter = new Supporter("table");
      var item = supporter.AddChild(null);

      Assert.That(item, Is.Null);
    }
    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 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 supporterHasChildrenReturnsFalseIfNoChildren()
    {
      Supporter supporter = new Supporter("table");

      Assert.That(supporter.HasChildren(), Is.False);
    }
 public void supporterCanNotWearItems()
 {
   Supporter supporter = new Supporter("table");
   var testDel = new TestDelegate(() => supporter.WearItem(new Thing("hatband")));
   Assert.That(testDel, Throws.TypeOf<CanNotWearItemsException>());
 }
 public void testPersonIsNotThingType()
 {
   Supporter supporter = new Supporter("table");
   Assert.That(supporter.IsThing, Is.False);
 }
 public void testPersonIsNotContainerType()
 {
   Supporter supporter = new Supporter("table");
   Assert.That(supporter.IsContainer, Is.False);
 }
 public void testPersonIsNotSupporterType()
 {
   Supporter supporter = new Supporter("table");
   Assert.That(supporter.IsSupporter, Is.True);
 }
 public void testPersonIsPersonType()
 {
   Supporter supporter = new Supporter("table");
   Assert.That(supporter.IsPerson, Is.False);
 }
    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;
    }