public void AddNull()
        {
            UnitGroup unitGroup = new UnitGroup();

            unitGroup.Add(null);
            Assert.Fail();
        }
        public void AddUnit()
        {
            Unit      unit      = new Unit("Test", 42, "Test Unit 42");
            UnitGroup unitGroup = new UnitGroup();

            unitGroup.Add(unit);
            Assert.AreEqual(unit.Id, unitGroup.Units.First().Id);
        }
        public void RemoveUnit()
        {
            Unit      unit      = new Unit("Test", 42, "Test Unit 42");
            UnitGroup unitGroup = new UnitGroup();

            unitGroup.Add(unit);
            unitGroup.Remove(unit);
            Assert.AreEqual(0, unitGroup.Units.Count);
        }
        public void GetUnit()
        {
            Unit      unit      = new Unit("Test", 42, "Test Unit 42");
            UnitGroup unitGroup = new UnitGroup();

            unitGroup.Add(unit);
            Unit gotUnit = unitGroup.GetUnit(unit.Id);

            Assert.AreEqual(unit.Name, gotUnit.Name);
        }
示例#5
0
 public void setGroup(UnitGroup newGroup)
 {
     if (group != null)
     {
         group.Remove(this);
         group = null;
     }
     if (newGroup != null)
     {
         newGroup.Add(this);
         group = newGroup;
     }
 }