Ejemplo n.º 1
0
        public void RefGridSlidersSample()
        {
            var    model      = ViewModel.Model;
            string samplePath = Path.Combine(workingDirectory, @".\Samples\refgridsliders.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            // check all the nodes and connectors are loaded
            Assert.GreaterOrEqual(8, model.CurrentWorkspace.Nodes.Count());
            Assert.GreaterOrEqual(10, model.CurrentWorkspace.Connectors.Count());
            AssertNoDummyNodes();

            // evaluate graph
            RunCurrentModel();

            var refPtNodeId = "69dcdcdc-941f-46f9-8e8b-242b61e74e80";

            AssertPreviewCount(refPtNodeId, 36);

            var refPt = GetPreviewValueAtIndex(refPtNodeId, 23) as ReferencePoint;

            Assert.IsNotNull(refPt);
            Assert.AreEqual(57, refPt.Y, 0.000001);

            // change slider value and re-evaluate graph
            DoubleSlider slider = model.CurrentWorkspace.NodeFromWorkspace("5adff29b-3cac-4387-8d1d-b75ceb9c6dec") as DoubleSlider;

            slider.Value = 3.5;

            RunCurrentModel();
            AssertPreviewCount(refPtNodeId, 16);
        }
Ejemplo n.º 2
0
        public void SliderValueResetsMax()
        {
            var slider = new DoubleSlider();
            Assert.NotNull(slider);

            slider.Value = 200;
            Assert.AreEqual(200.0, slider.Max);
        }
Ejemplo n.º 3
0
        public void SliderMaxNeverLessThanMin()
        {
            var slider = new DoubleSlider();
            Assert.NotNull(slider);

            slider.Max = -5;
            Assert.AreEqual(-5.0, slider.Min);
        }
Ejemplo n.º 4
0
        public void SliderValueResetsMin()
        {
            var slider = new DoubleSlider();
            Assert.NotNull(slider);

            slider.Value = -5;
            Assert.AreEqual(-5.0, slider.Min);
        }
Ejemplo n.º 5
0
        public void SliderMinNeverGreaterThanMax()
        {
            var slider = new DoubleSlider();
            Assert.NotNull(slider);

            slider.Min = 101;
            Assert.AreEqual(101.0, slider.Max);
        }
Ejemplo n.º 6
0
        public void SliderValueResetsMin()
        {
            var slider = new DoubleSlider();

            Assert.NotNull(slider);

            slider.Value = -5;
            Assert.AreEqual(-5.0, slider.Min);
        }
Ejemplo n.º 7
0
        public void SliderMaxNeverLessThanMin()
        {
            var slider = new DoubleSlider();

            Assert.NotNull(slider);

            slider.Max = -5;
            Assert.AreEqual(-5.0, slider.Min);
        }
Ejemplo n.º 8
0
        public void SliderMinNeverGreaterThanMax()
        {
            var slider = new DoubleSlider();

            Assert.NotNull(slider);

            slider.Min = 101;
            Assert.AreEqual(101.0, slider.Max);
        }
Ejemplo n.º 9
0
        public void SliderValueResetsMax()
        {
            var slider = new DoubleSlider();

            Assert.NotNull(slider);

            slider.Value = 200;
            Assert.AreEqual(200.0, slider.Max);
        }
Ejemplo n.º 10
0
        public void SliderASTGeneration()
        {
            var sliderNode = new DoubleSlider()
            {
                Value = 10
            };
            var buildOutput = sliderNode.BuildOutputAst(new List <AssociativeNode>());

            Assert.AreEqual(
                10,
                ((DoubleNode)((BinaryExpressionNode)buildOutput.First()).RightNode).Value);
        }
Ejemplo n.º 11
0
        public void SliderMaxValueWithBigNum()
        {
            var sliderNode = new DoubleSlider()
            {
                Value = 500
            };
            var updateValueParams = new UpdateValueParams("Max", "2.14748364712346E+15");

            sliderNode.UpdateValue(updateValueParams);

            Assert.AreEqual(
                2.14748364712346E+15,
                sliderNode.Max);
        }
Ejemplo n.º 12
0
        public void CreatePointEndSample()
        {
            var model = ViewModel.Model;

            string samplePath = Path.Combine(workingDirectory, @".\Samples\createpointend.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            // check all the nodes and connectors are loaded
            Assert.AreEqual(6, model.CurrentWorkspace.Nodes.Count());
            Assert.AreEqual(4, model.CurrentWorkspace.Connectors.Count());
            AssertNoDummyNodes();

            RunCurrentModel();

            // test copying and pasting the workflow
            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.AddRange(ViewModel.Model.CurrentWorkspace.Nodes);
            model.Copy();
            model.Paste();

            // evaluate graph
            var refPtNodeId = "16d1ceb2-c780-45d1-9dfb-d9c49836a931";
            var refPt       = GetPreviewValue(refPtNodeId) as ReferencePoint;

            Assert.IsNotNull(refPt);
            Assert.AreEqual(63.275, refPt.Z, 0.0000001);

            // change slider value and re-evaluate graph
            DoubleSlider slider = model.CurrentWorkspace.NodeFromWorkspace
                                      ("2eb70bdb-773d-4cf4-a10e-828dd39a0cca") as DoubleSlider;

            slider.Value = 56.78;

            RunCurrentModel();

            refPt = GetPreviewValue(refPtNodeId) as ReferencePoint;
            Assert.IsNotNull(refPt);
            Assert.AreEqual(56.78, refPt.Z);
        }
Ejemplo n.º 13
0
        public void SliderMaxValue()
        {
            var sliderNode = new DoubleSlider()
            {
                Value = 500
            };
            var updateValueParams = new UpdateValueParams("Value", "1000");

            sliderNode.UpdateValue(updateValueParams);

            Assert.AreEqual(
                1000,
                sliderNode.Max);

            updateValueParams = new UpdateValueParams("Value", "-1");
            sliderNode.UpdateValue(updateValueParams);

            Assert.AreEqual(
                -1,
                sliderNode.Min);
        }
Ejemplo n.º 14
0
        public void TestDoubleSliderInput()
        {
            var numNode = new DoubleSlider {
                X = 400, Value = 50.0, Max = 100.0, Min = 0.0
            };

            //To check if NodeModel base Serialization method is being called
            //To check if Double class's Serialization methods work

            //Assert initial values
            Assert.AreEqual(400, numNode.X);
            Assert.AreEqual(50.0, numNode.Value);
            Assert.AreEqual(0.0, numNode.Min);
            Assert.AreEqual(100.0, numNode.Max);

            //Serialize node and then change values
            XmlDocument xmlDoc       = new XmlDocument();
            XmlElement  serializedEl = numNode.Serialize(xmlDoc, SaveContext.Undo);

            numNode.X     = 250;
            numNode.Value = 4.0;
            numNode.Max   = 189.0;
            numNode.Min   = 2.0;

            //Assert new changes
            Assert.AreEqual(250, numNode.X);
            Assert.AreEqual(4.0, numNode.Value);
            Assert.AreEqual(2.0, numNode.Min);
            Assert.AreEqual(189.0, numNode.Max);

            //Deserialize and aasert old values
            numNode.Deserialize(serializedEl, SaveContext.Undo);
            Assert.AreEqual(400, numNode.X);
            Assert.AreEqual(50.0, numNode.Value);
            Assert.AreEqual(0.0, numNode.Min);
            Assert.AreEqual(100.0, numNode.Max);
        }
Ejemplo n.º 15
0
        public void DivideSelectedCurveSample()
        {
            var    model      = ViewModel.Model;
            string samplePath = Path.Combine(workingDirectory, @".\Samples\divideselectedcurve.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            // check all the nodes and connectors are loaded
            Assert.GreaterOrEqual(7, model.CurrentWorkspace.Nodes.Count());
            Assert.GreaterOrEqual(5, model.CurrentWorkspace.Connectors.Count());
            AssertNoDummyNodes();

            // evaluate graph
            RunCurrentModel();

            var refPtNodeId = "7e23ea22-600f-4263-89af-defa541e90f2";

            AssertPreviewCount(refPtNodeId, 33);

            var refPt = GetPreviewValueAtIndex(refPtNodeId, 3) as ReferencePoint;

            Assert.IsNotNull(refPt);
            //Assert.AreEqual(57, refPt.Y, 0.000001);

            // change slider value and re-evaluate graph
            DoubleSlider slider = model.CurrentWorkspace.NodeFromWorkspace
                                      ("a1844c0d-99bd-4a32-84f8-2e94685f3229") as DoubleSlider;

            slider.Value = 15.0;

            RunCurrentModel();
            AssertPreviewCount(refPtNodeId, 15);
            var refPt1 = GetPreviewValueAtIndex(refPtNodeId, 3) as ReferencePoint;

            Assert.IsNotNull(refPt1);
        }
Ejemplo n.º 16
0
        public void CanConstructDoubleSlider()
        {
            var slider = new DoubleSlider();

            Assert.NotNull(slider);
        }
Ejemplo n.º 17
0
 public void CanConstructDoubleSlider()
 {
     var slider = new DoubleSlider();
     Assert.NotNull(slider);
 }
Ejemplo n.º 18
0
        public void TestDoubleSliderInput()
        {
            var numNode = new DoubleSlider { X = 400, Value = 50.0, Max = 100.0, Min = 0.0 };

            //To check if NodeModel base Serialization method is being called
            //To check if Double class's Serialization methods work

            //Assert initial values
            Assert.AreEqual(400, numNode.X);
            Assert.AreEqual(50.0, numNode.Value);
            Assert.AreEqual(0.0, numNode.Min);
            Assert.AreEqual(100.0, numNode.Max);

            //Serialize node and then change values
            XmlDocument xmlDoc = new XmlDocument();
            XmlElement serializedEl = numNode.Serialize(xmlDoc, SaveContext.Undo);
            numNode.X = 250;
            numNode.Value = 4.0;
            numNode.Max = 189.0;
            numNode.Min = 2.0;

            //Assert new changes
            Assert.AreEqual(250, numNode.X);
            Assert.AreEqual(4.0, numNode.Value);
            Assert.AreEqual(2.0, numNode.Min);
            Assert.AreEqual(189.0, numNode.Max);

            //Deserialize and aasert old values
            numNode.Deserialize(serializedEl, SaveContext.Undo);
            Assert.AreEqual(400, numNode.X);
            Assert.AreEqual(50.0, numNode.Value);
            Assert.AreEqual(0.0, numNode.Min);
            Assert.AreEqual(100.0, numNode.Max);
        }