コード例 #1
0
        public void ShouldSyncItsContainerWithModelParents()
        {
            var model_a = new Model ("a");
            var model_b = new Model ("b");
            var model_container = new Model("container");
            var models = new ModelCollection(model_container);
            models.AddRange(new [] {model_a, model_b});

            Assert.That(models.Container, Is.EqualTo(model_container));
            Assert.That(models.All(m => m.Parent == model_container));

            models.Clear();

            Assert.That(model_a.Parent, Is.Null);
            Assert.That(model_b.Parent, Is.Null);

            models.Add(model_a);

            Assert.That(model_a.Parent, Is.EqualTo(model_container));

            models.Insert(0, model_b);

            Assert.That(model_b.Parent, Is.EqualTo(model_container));

            models.Remove(model_a);

            Assert.That(model_a.Parent, Is.Null);
        }
コード例 #2
0
ファイル: Model.cs プロジェクト: calvinkwong/pol-the-game
 public Model(Model parent, Model owner, string key)
 {
     if(string.IsNullOrEmpty(key))
     throw new ArgumentException("Name cannot be null or empty!", "key");
       this.parent = parent;
       this.owner = owner;
       this.key = key;
 }
コード例 #3
0
ファイル: Model.cs プロジェクト: calvinkwong/pol-the-game
        internal void SetParent(Model parent)
        {
            this.parent = parent;

              OnParentChanged();
        }
コード例 #4
0
ファイル: Model.cs プロジェクト: calvinkwong/pol-the-game
 public Model(Model owner, string key)
     : this(null, owner, key)
 {
 }