Ejemplo n.º 1
0
        public void TestRemoveVertices()
        {
            var path = new JuiceStreamPath();

            path.Add(10, 5);
            path.Add(20, -5);

            int removeCount = path.RemoveVertices((v, i) => v.Distance == 10 && i == 1);

            Assert.That(removeCount, Is.EqualTo(1));
            Assert.That(path.Vertices, Is.EqualTo(new[]
            {
                new JuiceStreamPathVertex(0, 0),
                new JuiceStreamPathVertex(20, -5)
            }));

            removeCount = path.RemoveVertices((_, i) => i == 0);
            Assert.That(removeCount, Is.EqualTo(1));
            Assert.That(path.Vertices, Is.EqualTo(new[]
            {
                new JuiceStreamPathVertex(20, -5)
            }));

            removeCount = path.RemoveVertices((_, i) => true);
            Assert.That(removeCount, Is.EqualTo(1));
            Assert.That(path.Vertices, Is.EqualTo(new[]
            {
                new JuiceStreamPathVertex()
            }));
        }
Ejemplo n.º 2
0
        public void TestInvalidation()
        {
            var path = new JuiceStreamPath();

            Assert.That(path.InvalidationID, Is.EqualTo(1));
            int previousId = path.InvalidationID;

            path.InsertVertex(10);
            checkNewId();

            path.SetVertexPosition(1, 5);
            checkNewId();

            path.Add(20, 0);
            checkNewId();

            path.RemoveVertices((v, _) => v.Distance == 20);
            checkNewId();

            path.ResampleVertices(new double[] { 5, 10, 15 });
            checkNewId();

            path.Clear();
            checkNewId();

            path.ConvertFromSliderPath(new SliderPath());
            checkNewId();

            void checkNewId()
            {
                Assert.That(path.InvalidationID, Is.Not.EqualTo(previousId));
                previousId = path.InvalidationID;
            }
        }