コード例 #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);
        }
コード例 #2
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);
        }
コード例 #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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
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"));
        }
コード例 #7
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"));
        }
コード例 #8
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"));
        }
コード例 #9
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());
        }
コード例 #10
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"));
        }
コード例 #11
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());
        }
コード例 #12
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);
        }
コード例 #13
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"));
        }
コード例 #14
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"));
        }
コード例 #15
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"));
        }
コード例 #16
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"));
        }