コード例 #1
0
        public void OneCollectionOneItemTest()
        {
            var c = new CollectionViewModel();
            var i = new ItemViewModel();

            Assert.AreEqual(null, i.Collection);
            Assert.AreEqual(0, c.Count);

            i.Collection = c;

            Assert.AreEqual(c, i.Collection);
            Assert.AreEqual(1, c.Count);

            i.Collection = null;

            Assert.AreEqual(null, i.Collection);
            Assert.AreEqual(0, c.Count);

            c.Add(i);

            Assert.AreEqual(c, i.Collection);
            Assert.AreEqual(1, c.Count);

            c.Remove(i);

            Assert.AreEqual(null, i.Collection);
            Assert.AreEqual(0, c.Count);
        }