public void OneItemOneCollectionPropertyTest() { var sc = new SmartCollection <TestItem, object>(new object()); var si = new TestItem(); Assert.AreEqual(null, si.Collection); si.Collection = sc; Assert.AreEqual(sc, si.Collection); Assert.IsTrue(sc.Contains(si)); si.Collection = null; Assert.AreEqual(null, si.Collection); Assert.IsFalse(sc.Contains(si)); }
public void OneItemOneCollectionAddTest() { var sc = new SmartCollection <TestItem, object>(new object()); var si = new TestItem(); Assert.AreEqual(null, si.Collection); sc.Add(si); Assert.AreEqual(sc, si.Collection); Assert.IsTrue(sc.Contains(si)); }
public void ResetTest() { var sc = new SmartCollection <TestItem, object>(new object()); var si1 = new TestItem(); var si2 = new TestItem(); var si3 = new TestItem(); sc.Add(si1); si2.Collection = sc; sc.Add(si3); Assert.AreEqual(sc, si1.Collection); Assert.AreEqual(sc, si2.Collection); Assert.AreEqual(sc, si3.Collection); Assert.IsTrue(sc.Contains(si1)); Assert.IsTrue(sc.Contains(si2)); Assert.IsTrue(sc.Contains(si3)); sc.Clear(); Assert.AreEqual(null, si1.Collection); Assert.AreEqual(null, si2.Collection); Assert.AreEqual(null, si3.Collection); Assert.IsFalse(sc.Contains(si1)); Assert.IsFalse(sc.Contains(si2)); Assert.IsFalse(sc.Contains(si3)); }
public void SmartCollectionConstructorTest() { IEnumerable <int> enumerable = new List <int>() { 1 }; SmartCollection <int> smartCollection = new SmartCollection <int>(enumerable); Assert.AreEqual(1, smartCollection.Count); Assert.IsTrue(smartCollection.Contains(1)); var list = new List <int>() { 1, 2 }; smartCollection = new SmartCollection <int>(list); Assert.AreEqual(2, smartCollection.Count); Assert.IsTrue(smartCollection.Contains(1)); Assert.IsTrue(smartCollection.Contains(2)); }
public void OneItemTwoCollectionsPropertyTest() { var sc1 = new SmartCollection <TestItem, object>(new object()); var sc2 = new SmartCollection <TestItem, object>(new object()); var si = new TestItem(); si.Collection = sc1; si.Collection = sc2; Assert.AreEqual(sc2, si.Collection); Assert.IsFalse(sc1.Contains(si)); Assert.IsTrue(sc2.Contains(si)); }