public void TestAdd() { AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(new CoalescableAffector()); affectors.Add(new NoncoalescableAffector()); Assert.AreEqual(2, affectors.Count); Assert.AreEqual(1, affectors.CoalescableAffectors.Count); Assert.AreEqual(1, affectors.NoncoalescableAffectors.Count); }
public void TestThrowOnCopyToAsObject() { CoalescableAffector coalescable = new CoalescableAffector(); NoncoalescableAffector noncoalescable = new NoncoalescableAffector(); AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(coalescable); affectors.Add(noncoalescable); object[] array = new object[3]; Assert.Throws <IndexOutOfRangeException>( delegate() { (affectors as ICollection).CopyTo(array, 2); } ); }
public void TestThrowOnCopyTo() { CoalescableAffector coalescable = new CoalescableAffector(); NoncoalescableAffector noncoalescable = new NoncoalescableAffector(); AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(coalescable); affectors.Add(noncoalescable); IParticleAffector <int>[] array = new IParticleAffector <int> [3]; Assert.Throws <IndexOutOfRangeException>( delegate() { affectors.CopyTo(array, 2); } ); }
public void TestContains() { CoalescableAffector coalescable = new CoalescableAffector(); NoncoalescableAffector noncoalescable = new NoncoalescableAffector(); AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(coalescable); affectors.Add(noncoalescable); Assert.IsTrue(affectors.Contains(coalescable)); Assert.IsFalse(affectors.Contains(new CoalescableAffector())); Assert.IsTrue(affectors.Contains(noncoalescable)); Assert.IsFalse(affectors.Contains(new NoncoalescableAffector())); }
public void TestAdvanceEnumeratorPastEnd() { AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(new CoalescableAffector()); affectors.Add(new NoncoalescableAffector()); using ( IEnumerator <IParticleAffector <int> > enumerator = affectors.GetEnumerator() ) { Assert.IsTrue(enumerator.MoveNext()); Assert.IsTrue(enumerator.MoveNext()); Assert.IsFalse(enumerator.MoveNext()); Assert.IsFalse(enumerator.MoveNext()); Assert.IsFalse(enumerator.MoveNext()); } }
public void TestCopyToAsObject() { CoalescableAffector coalescable = new CoalescableAffector(); NoncoalescableAffector noncoalescable = new NoncoalescableAffector(); AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(coalescable); affectors.Add(noncoalescable); object[] array = new object[3]; (affectors as ICollection).CopyTo(array, 1); Assert.IsNull(array[0]); Assert.Contains(coalescable, array); Assert.Contains(noncoalescable, array); }
public void TestCopyTo() { CoalescableAffector coalescable = new CoalescableAffector(); NoncoalescableAffector noncoalescable = new NoncoalescableAffector(); AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(coalescable); affectors.Add(noncoalescable); IParticleAffector <int>[] array = new IParticleAffector <int> [3]; affectors.CopyTo(array, 1); Assert.IsNull(array[0]); Assert.Contains(coalescable, array); Assert.Contains(noncoalescable, array); }
public void TestCurrentAsObject() { NoncoalescableAffector affector = new NoncoalescableAffector(); AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(affector); IEnumerator enumerator = (affectors as ICollection).GetEnumerator(); Assert.IsTrue(enumerator.MoveNext()); Assert.AreSame(affector, enumerator.Current); Assert.IsFalse(enumerator.MoveNext()); }
public void TestCurrent() { NoncoalescableAffector affector = new NoncoalescableAffector(); AffectorCollection <int> affectors = new AffectorCollection <int>(); affectors.Add(affector); using ( IEnumerator <IParticleAffector <int> > enumerator = affectors.GetEnumerator() ) { Assert.IsTrue(enumerator.MoveNext()); Assert.AreSame(affector, enumerator.Current); Assert.IsFalse(enumerator.MoveNext()); } }