Example #1
0
        public void Add()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());

            Assert.Throws <ArgumentNullException>(() => ppc.AddUniform <float>(null));
            Assert.Throws <ArgumentException>(() => ppc.AddUniform <float>(""));
            Assert.Throws <ArgumentNullException>(() => ppc.AddVarying <float>(null));
            Assert.Throws <ArgumentException>(() => ppc.AddVarying <float>(""));

            var pu = ppc.AddUniform <float>("F");

            Assert.IsTrue(pu.Values == null);
            Assert.Throws <ParticleSystemException>(() => ppc.AddUniform <int>("F"));
            Assert.Throws <ParticleSystemException>(() => ppc.AddVarying <int>("F"));

            var pv = ppc.AddVarying <float>("V");

            Assert.IsTrue(pv.Values != null);
            Assert.Throws <ParticleSystemException>(() => ppc.AddUniform <int>("V"));
            Assert.Throws <ParticleSystemException>(() => ppc.AddVarying <int>("V"));

            // Test overriding.
            Assert.AreEqual(pu, ppc.AddUniform <float>("F"));
            Assert.AreEqual(pv, ppc.AddUniform <float>("V"));
            Assert.AreEqual(pv, ppc.AddVarying <float>("V"));

            var pvv = ppc.AddVarying <float>("F");

            Assert.AreNotEqual(pv, pvv);
        }
        public void Add()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());

              Assert.Throws<ArgumentNullException>(() => ppc.AddUniform<float>(null));
              Assert.Throws<ArgumentException>(() => ppc.AddUniform<float>(""));
              Assert.Throws<ArgumentNullException>(() => ppc.AddVarying<float>(null));
              Assert.Throws<ArgumentException>(() => ppc.AddVarying<float>(""));

              var pu = ppc.AddUniform<float>("F");
              Assert.IsTrue(pu.Values == null);
              Assert.Throws<ParticleSystemException>(() => ppc.AddUniform<int>("F"));
              Assert.Throws<ParticleSystemException>(() => ppc.AddVarying<int>("F"));

              var pv = ppc.AddVarying<float>("V");
              Assert.IsTrue(pv.Values != null);
              Assert.Throws<ParticleSystemException>(() => ppc.AddUniform<int>("V"));
              Assert.Throws<ParticleSystemException>(() => ppc.AddVarying<int>("V"));

              // Test overriding.
              Assert.AreEqual(pu, ppc.AddUniform<float>("F"));
              Assert.AreEqual(pv, ppc.AddUniform<float>("V"));
              Assert.AreEqual(pv, ppc.AddVarying<float>("V"));

              var pvv = ppc.AddVarying<float>("F");
              Assert.AreNotEqual(pv, pvv);
        }
Example #3
0
        public void UpdateArrays()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
            var pu  = ppc.AddUniform <float>("U");
            var pv  = ppc.AddVarying <float>("V");

            ppc.ParticleSystem.MaxNumberOfParticles = 71;
            ppc.UpdateArrayLength();
            Assert.AreEqual(71, pv.Values.Length);
        }
Example #4
0
        public void Contains()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());

            Assert.IsFalse(ppc.Contains("A"));

            ppc.AddVarying <float>("A");
            ppc.AddUniform <float>("B");

            Assert.IsTrue(ppc.Contains("A"));
            Assert.IsFalse(ppc.Contains("C"));
        }
Example #5
0
        public void TryGet()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
            var pu  = ppc.AddUniform <float>("U");
            var pv  = ppc.AddVarying <float>("V");

            Assert.AreEqual(null, ppc.GetUnchecked <float>(null));
            Assert.AreEqual(null, ppc.GetUnchecked <float>(""));
            Assert.AreEqual(pu, ppc.GetUnchecked <float>("U"));
            Assert.AreEqual(pv, ppc.GetUnchecked <float>("V"));
            Assert.AreEqual(null, ppc.GetUnchecked <int>("V"));
        }
Example #6
0
        public void Get()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
            var pu  = ppc.AddUniform <float>("U");
            var pv  = ppc.AddVarying <float>("V");

            Assert.AreEqual(null, ppc.Get <float>(null));
            Assert.AreEqual(null, ppc.Get <float>(""));
            Assert.AreEqual(pu, ppc.Get <float>("U"));
            Assert.AreEqual(pv, ppc.Get <float>("V"));
            Assert.Throws <ParticleSystemException>(() => ppc.Get <int>("U"));
        }
Example #7
0
        public void Clear()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());

            ppc.Clear();
            Assert.AreEqual(0, ppc.Count());

            ppc.AddVarying <float>("A");
            ppc.AddUniform <float>("B");

            ppc.Clear();
            Assert.AreEqual(0, ppc.Count());
        }
Example #8
0
        public void Remove()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
            var pu  = ppc.AddUniform <float>("U");
            var pv  = ppc.AddVarying <float>("V");

            Assert.AreEqual(false, ppc.Remove(null));
            Assert.AreEqual(false, ppc.Remove(""));
            Assert.AreEqual(true, ppc.Remove("U"));
            Assert.AreEqual(false, ppc.Remove("U"));
            Assert.AreEqual(true, ppc.Remove("V"));
            Assert.AreEqual(false, ppc.Remove("V"));
        }
Example #9
0
        public void Changed()
        {
            bool changed = false;

            var ppc = new ParticleParameterCollection(new ParticleSystem());

            ppc.Changed += (s, e) => changed = true;

            ppc.Clear();
            Assert.IsFalse(changed);

            ppc.AddVarying <float>("D");
            Assert.IsTrue(changed);

            changed = false;
            ppc.AddUniform <float>("F");
            Assert.IsTrue(changed);

            changed = false;
            ppc.AddUniform <float>("F");
            Assert.IsFalse(changed);

            changed = false;
            ppc.AddVarying <float>("F");
            Assert.IsTrue(changed);

            changed = false;
            ppc.AddUniform <float>("F");
            Assert.IsFalse(changed);

            changed = false;
            ppc.AddVarying <float>("F");
            Assert.IsFalse(changed);

            changed = false;
            ppc.Remove("D");
            Assert.IsTrue(changed);

            changed = false;
            ppc.Clear();
            Assert.IsTrue(changed);
        }
        public void Changed()
        {
            bool changed = false;

              var ppc = new ParticleParameterCollection(new ParticleSystem());
              ppc.Changed += (s, e) => changed = true;

              ppc.Clear();
              Assert.IsFalse(changed);

              ppc.AddVarying<float>("D");
              Assert.IsTrue(changed);

              changed = false;
              ppc.AddUniform<float>("F");
              Assert.IsTrue(changed);

              changed = false;
              ppc.AddUniform<float>("F");
              Assert.IsFalse(changed);

              changed = false;
              ppc.AddVarying<float>("F");
              Assert.IsTrue(changed);

              changed = false;
              ppc.AddUniform<float>("F");
              Assert.IsFalse(changed);

              changed = false;
              ppc.AddVarying<float>("F");
              Assert.IsFalse(changed);

              changed = false;
              ppc.Remove("D");
              Assert.IsTrue(changed);

              changed = false;
              ppc.Clear();
              Assert.IsTrue(changed);
        }
        public void Clear()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());

              ppc.Clear();
              Assert.AreEqual(0, ppc.Count());

              ppc.AddVarying<float>("A");
              ppc.AddUniform<float>("B");

              ppc.Clear();
              Assert.AreEqual(0, ppc.Count());
        }
        public void UpdateArrays()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
              var pu = ppc.AddUniform<float>("U");
              var pv = ppc.AddVarying<float>("V");

              ppc.ParticleSystem.MaxNumberOfParticles = 71;
              ppc.UpdateArrayLength();
              Assert.AreEqual(71, pv.Values.Length);
        }
        public void TryGet()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
              var pu = ppc.AddUniform<float>("U");
              var pv = ppc.AddVarying<float>("V");

              Assert.AreEqual(null, ppc.GetUnchecked<float>(null));
              Assert.AreEqual(null, ppc.GetUnchecked<float>(""));
              Assert.AreEqual(pu, ppc.GetUnchecked<float>("U"));
              Assert.AreEqual(pv, ppc.GetUnchecked<float>("V"));
              Assert.AreEqual(null, ppc.GetUnchecked<int>("V"));
        }
        public void Remove()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
              var pu = ppc.AddUniform<float>("U");
              var pv = ppc.AddVarying<float>("V");

              Assert.AreEqual(false, ppc.Remove(null));
              Assert.AreEqual(false, ppc.Remove(""));
              Assert.AreEqual(true, ppc.Remove("U"));
              Assert.AreEqual(false, ppc.Remove("U"));
              Assert.AreEqual(true, ppc.Remove("V"));
              Assert.AreEqual(false, ppc.Remove("V"));
        }
        public void Get()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());
              var pu = ppc.AddUniform<float>("U");
              var pv = ppc.AddVarying<float>("V");

              Assert.AreEqual(null, ppc.Get<float>(null));
              Assert.AreEqual(null, ppc.Get<float>(""));
              Assert.AreEqual(pu, ppc.Get<float>("U"));
              Assert.AreEqual(pv, ppc.Get<float>("V"));
              Assert.Throws<ParticleSystemException>(() => ppc.Get<int>("U"));
        }
        public void Contains()
        {
            var ppc = new ParticleParameterCollection(new ParticleSystem());

              Assert.IsFalse(ppc.Contains("A"));

              ppc.AddVarying<float>("A");
              ppc.AddUniform<float>("B");

              Assert.IsTrue(ppc.Contains("A"));
              Assert.IsFalse(ppc.Contains("C"));
        }