public void AddNullTest()
 {
     var c = new ParticleModifierCollection
     { new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false) };
     var initial = c.ToArray();
     Assert.IsTrue(c.ContainSameElements(initial));
     ConsistencyAsserts(c);
     c.Add(null);
     Assert.IsTrue(c.ContainSameElements(initial));
     ConsistencyAsserts(c);
 }
        public void AddNullTest()
        {
            var c = new ParticleModifierCollection
            {
                new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false)
            };
            var initial = c.ToArray();

            Assert.IsTrue(c.ContainSameElements(initial));
            ConsistencyAsserts(c);
            c.Add(null);
            Assert.IsTrue(c.ContainSameElements(initial));
            ConsistencyAsserts(c);
        }
        public void ToListTest()
        {
            var c = new ParticleModifierCollection
            {
                new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false)
            };

            var a = c.ToList();

            Assert.IsTrue(c.ContainSameElements(a));
            Assert.AreEqual(c.Count, a.Count);
        }
        public void DeepCopyTest()
        {
            var c = new ParticleModifierCollection
            {
                new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false)
            };

            ConsistencyAsserts(c);
            var copy = c.DeepCopy();

            ConsistencyAsserts(copy);
            Assert.IsTrue(c.ContainSameElements(copy));
            Assert.IsTrue(c.ReleaseModifiers.ContainSameElements(copy.ReleaseModifiers));
            Assert.IsTrue(c.UpdateModifiers.ContainSameElements(copy.UpdateModifiers));
        }
        static void ConsistencyAsserts(ParticleModifierCollection c)
        {
            Assert.AreEqual(c.Count(x => x.ProcessOnRelease), c.ReleaseModifiers.Count(), "Sub-list has too many or too few elements.");
            Assert.AreEqual(c.Count(x => x.ProcessOnUpdate), c.UpdateModifiers.Count(), "Sub-list has too many or too few elements.");

            Assert.IsTrue(c.Where(x => x.ProcessOnRelease).ContainSameElements(c.ReleaseModifiers), "Sub-list does not match main list for given value.");
            Assert.IsTrue(c.Where(x => x.ProcessOnUpdate).ContainSameElements(c.UpdateModifiers), "Sub-list does not match main list for given value.");

            Assert.IsFalse(c.Any(x => x == null), "Shouldn't be able to add null items.");

            Assert.AreEqual(c.HasReleaseModifiers, !c.ReleaseModifiers.IsEmpty());
            Assert.AreEqual(c.HasUpdateModifiers, !c.UpdateModifiers.IsEmpty());

            var concatDistinct = c.ReleaseModifiers.Concat(c.UpdateModifiers).Distinct();
            Assert.IsTrue(c.ContainSameElements(concatDistinct), "Sub-collections don't contain same items as main collection.");
        }
        static void ConsistencyAsserts(ParticleModifierCollection c)
        {
            Assert.AreEqual(c.Count(x => x.ProcessOnRelease), c.ReleaseModifiers.Count(), "Sub-list has too many or too few elements.");
            Assert.AreEqual(c.Count(x => x.ProcessOnUpdate), c.UpdateModifiers.Count(), "Sub-list has too many or too few elements.");

            Assert.IsTrue(c.Where(x => x.ProcessOnRelease).ContainSameElements(c.ReleaseModifiers), "Sub-list does not match main list for given value.");
            Assert.IsTrue(c.Where(x => x.ProcessOnUpdate).ContainSameElements(c.UpdateModifiers), "Sub-list does not match main list for given value.");

            Assert.IsFalse(c.Any(x => x == null), "Shouldn't be able to add null items.");

            Assert.AreEqual(c.HasReleaseModifiers, !c.ReleaseModifiers.IsEmpty());
            Assert.AreEqual(c.HasUpdateModifiers, !c.UpdateModifiers.IsEmpty());

            var concatDistinct = c.ReleaseModifiers.Concat(c.UpdateModifiers).Distinct();

            Assert.IsTrue(c.ContainSameElements(concatDistinct), "Sub-collections don't contain same items as main collection.");
        }
 public void DeepCopyTest()
 {
     var c = new ParticleModifierCollection
     { new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false) };
     ConsistencyAsserts(c);
     var copy = c.DeepCopy();
     ConsistencyAsserts(copy);
     Assert.IsTrue(c.ContainSameElements(copy));
     Assert.IsTrue(c.ReleaseModifiers.ContainSameElements(copy.ReleaseModifiers));
     Assert.IsTrue(c.UpdateModifiers.ContainSameElements(copy.UpdateModifiers));
 }
        public void ToListTest()
        {
            var c = new ParticleModifierCollection
            { new TestModifierA(false, true), new TestModifierA(true, true), new TestModifierA(true, false) };

            var a = c.ToList();
            Assert.IsTrue(c.ContainSameElements(a));
            Assert.AreEqual(c.Count, a.Count);
        }