Example #1
0
        public void TestGetEnumeratorForObject()
        {
            AffectorCollection <int> affectors = new AffectorCollection <int>();
            IEnumerator enumerator             = (affectors as ICollection).GetEnumerator();

            Assert.IsNotNull(enumerator);
            Assert.IsFalse(enumerator.MoveNext());
        }
Example #2
0
        public void TestGetEnumerator()
        {
            AffectorCollection <int> affectors = new AffectorCollection <int>();

            using (IEnumerator <IParticleAffector <int> > enumerator = affectors.GetEnumerator()) {
                Assert.IsNotNull(enumerator);
                Assert.IsFalse(enumerator.MoveNext());
            }
        }
Example #3
0
        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);
        }
Example #4
0
            public void TestThrowOnCurrentFromInvalidPosition()
            {
                AffectorCollection <int> affectors = new AffectorCollection <int>();

                using (
                    IEnumerator <IParticleAffector <int> > enumerator = affectors.GetEnumerator()
                    ) {
                    Assert.Throws <InvalidOperationException>(
                        delegate() { Assert.AreNotEqual(enumerator.Current, enumerator.Current); }
                        );
                }
            }
Example #5
0
            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());
            }
Example #6
0
        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); }
                );
        }
Example #7
0
        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); }
                );
        }
Example #8
0
            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());
                }
            }
Example #9
0
        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()));
        }
Example #10
0
            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());
                }
            }
Example #11
0
        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);
        }
Example #12
0
        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);
        }
Example #13
0
        public void TestIsSynchronized()
        {
            AffectorCollection <int> affectors = new AffectorCollection <int>();

            Assert.IsFalse((affectors as ICollection).IsSynchronized);
        }
Example #14
0
        public void TestSyncRoot()
        {
            AffectorCollection <int> affectors = new AffectorCollection <int>();

            lock ((affectors as ICollection).SyncRoot) { }
        }
Example #15
0
        public void TestIsReadOnly()
        {
            AffectorCollection <int> affectors = new AffectorCollection <int>();

            Assert.IsFalse(affectors.IsReadOnly);
        }
Example #16
0
        public void TestConstructor()
        {
            AffectorCollection <int> affectors = new AffectorCollection <int>();

            Assert.IsNotNull(affectors); // nonsense; prevents compiler warning
        }