Пример #1
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);
        }