Example #1
0
        public static void Test()
        {
            string         name = "nameasd";
            Id <Parameter> id   = Id <Parameter> .Parse("C6AE15FF-0242-4289-AADD-F9F71F4CFEBB");

            ParameterType type = ParameterType.Parse("86EDCBA3-7807-4DD5-B0E8-0769C52BA0EB");

            DecimalParameter.Definition definition = new DecimalParameter.Definition(-100, 100);
            DecimalParameter            p          = new DecimalParameter(name, id, type, definition, "2");

            TestParameterIs(p, 2);

            //Test range checking
            Assert.That(() => p.SetValueAction(-100.1m), Throws.ArgumentException);
            TestParameterIs(p, 2);
            Assert.That(() => p.SetValueAction(100.1m), Throws.ArgumentException);
            TestParameterIs(p, 2);

            using (TemporaryCulture.European()) //To make sure we handle decimal separator properly
            {
                //Test undo/redo
                var actions = p.SetValueAction(12.4m);
                Assert.That(actions, Is.Not.Null);
                TestParameterIs(p, 2);
                actions.Value.Redo();
                TestParameterIs(p, 12.4m);
                actions.Value.Undo();
                TestParameterIs(p, 2);

                p.TryDeserialiseValue("shane");
                TestCorruptParameter(p, "shane");

                //Test what happens if we undo back to an invalid state
                var actions2 = p.SetValueAction(1.0m);
                actions2.Value.Redo();
                actions2.Value.Undo();
                TestCorruptParameter(p, "shane");

                p.TryDeserialiseValue("54.45");
                TestParameterIs(p, 54.45m);
            }
        }
Example #2
0
        public static void TestNullDefault()
        {
            string         name = "nameasd";
            Id <Parameter> id   = Id <Parameter> .Parse("C6AE15FF-0242-4289-AADD-F9F71F4CFEBB");

            ParameterType type = ParameterType.Parse("86EDCBA3-7807-4DD5-B0E8-0769C52BA0EB");

            DecimalParameter.Definition definition = new DecimalParameter.Definition(null, null);
            DecimalParameter            p          = new DecimalParameter(name, id, type, definition, null);

            Assert.That(p.Corrupted, Is.True);
            p.SetValueAction(1).Value.Redo();
            TestParameterIs(p, 1);
        }