Пример #1
0
        public static void TestBasicConstruction()
        {
            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(min: null, max: null);
                DecimalParameter            p          = new DecimalParameter(name, id, type, definition, null);
                Assert.That(p.Id, Is.EqualTo(id));
                Assert.That(p.Name, Is.EqualTo(name));
                Assert.That(p.TypeId, Is.EqualTo(type));
                Assert.That(p.Min, Is.EqualTo(decimal.MinValue));
                Assert.That(p.Max, Is.EqualTo(decimal.MaxValue));
            }
            {
                DecimalParameter.Definition definition = new DecimalParameter.Definition(min: null, max: 45.23m);
                DecimalParameter            p          = new DecimalParameter(name, id, type, definition, null);
                Assert.That(p.Id, Is.EqualTo(id));
                Assert.That(p.Name, Is.EqualTo(name));
                Assert.That(p.TypeId, Is.EqualTo(type));
                Assert.That(p.Min, Is.EqualTo(decimal.MinValue));
                Assert.That(p.Max, Is.EqualTo(45.23m));
            }
            {
                DecimalParameter.Definition definition = new DecimalParameter.Definition(min: -1232.3m, max: null);
                DecimalParameter            p          = new DecimalParameter(name, id, type, definition, null);
                Assert.That(p.Id, Is.EqualTo(id));
                Assert.That(p.Name, Is.EqualTo(name));
                Assert.That(p.TypeId, Is.EqualTo(type));
                Assert.That(p.Min, Is.EqualTo(-1232.3m));
                Assert.That(p.Max, Is.EqualTo(decimal.MaxValue));
            }
            {
                DecimalParameter.Definition definition = new DecimalParameter.Definition(min: -34985.412m, max: 34986.34m);
                DecimalParameter            p          = new DecimalParameter(name, id, type, definition, null);
                Assert.That(p.Id, Is.EqualTo(id));
                Assert.That(p.Name, Is.EqualTo(name));
                Assert.That(p.TypeId, Is.EqualTo(type));
                Assert.That(p.Min, Is.EqualTo(-34985.412m));
                Assert.That(p.Max, Is.EqualTo(34986.34m));
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
            public GraphData(Id <NodeTemp> nodeId, Id <NodeTypeTemp> nodeTypeId, IEnumerable <NodeDataGeneratorParameterData> parameterData)
            {
                NodeId     = nodeId;
                NodeTypeId = nodeTypeId;

                var allConnectorsDefinition = new ConnectorDefinitionData(null, null, null, null, false);

                var outputs    = new List <Output>();
                var parameters = new List <IParameter>();

                DecimalParameter.Definition d = new DecimalParameter.Definition(null, null);
                ParameterType decimalType     = ParameterType.Basic.Parse("721796b6-a242-4723-82e9-35201097e675");
                ParameterType dynamicEnumType = ParameterType.Basic.Parse("6d2d52c8-5934-4ba8-8d4e-7081fe57f662");

                DynamicEnumParameter.Source source = new DynamicEnumParameter.Source();
                IEnumeration  enumeration          = new DummyEnumeration();
                ParameterType integerEnumType      = ParameterType.Basic.Parse("de108fdb-db50-4cd5-aad5-0ea791f04721");

                IntegerParameter.Definition i = new IntegerParameter.Definition(null, null);

                AudioParameter           = new AudioParameter("Audio", Id <Parameter> .Parse("3ac8d0ca-c9f6-4e06-b18c-c1366e1af7d3"));
                BooleanParameter         = new BooleanParameter("Boolean", Id <Parameter> .Parse("0e12e8e3-4c95-43a5-a733-d2d1fbbb780c"), "false");
                DecimalParameter         = new DecimalParameter("Decimal", Id <Parameter> .Parse("765e616a-f165-4053-a15c-14ed593429af"), decimalType, d, "1.0");
                DynamicEnumParameter     = new DynamicEnumParameter("DynamicEnum", Id <Parameter> .Parse("7c5b019c-79d0-4ef0-b848-0a2c68908f34"), source, dynamicEnumType, "shnae", false);
                EnumParameter            = new EnumParameter("Enum", Id <Parameter> .Parse("e576713b-5d45-48d0-8a4e-661f1fedcafd"), enumeration, enumeration.DefaultValue.ToString());
                IntegerParameter         = new IntegerParameter("Int", Id <Parameter> .Parse("275d75f3-fe4e-42b1-bfaf-e841ba591999"), integerEnumType, i, "1");
                LocalizedStringParameter = new LocalizedStringParameter("Localized stirng", Id <Parameter> .Parse("f332e619-e9a3-421f-9851-d95a00b62da9"), ParameterType.Basic.Parse("4547dbf2-46cc-4c84-ac6e-81ab185575dc"));
                SetParameter             = new SetParameter("Set", Id <Parameter> .Parse("2d6235ea-c8a1-447a-b9d8-692f6329be33"), enumeration, null);
                StringParameter          = new StringParameter("string", Id <Parameter> .Parse("4752d30e-e1ab-47ba-bc15-b2e6ecfa5416"));
                StringParameter2         = new StringParameter("string2", Id <Parameter> .Parse("dcd4a349-b0a8-4fa3-8989-2d10469b1a17"));

                if (nodeTypeId == TYPE1)
                {
                    outputs.Add(new Output(Id <TConnector> .Parse("0956c9d3-c230-49a2-874a-7e3747b58cff"), allConnectorsDefinition, this, null, DummyRules.Instance));
                    parameters.Add(AudioParameter);
                    parameters.Add(BooleanParameter);
                    parameters.Add(DecimalParameter);
                    parameters.Add(DynamicEnumParameter);
                    parameters.Add(EnumParameter);
                }
                else if (nodeTypeId == TYPE2)
                {
                    outputs.Add(new Output(Id <TConnector> .Parse("da2b4ded-378e-4484-89f0-1328a42f00e3"), allConnectorsDefinition, this, null, DummyRules.Instance));
                    outputs.Add(new Output(Id <TConnector> .Parse("2bf2ca93-6b81-4a9a-814f-809a8bef332f"), allConnectorsDefinition, this, null, DummyRules.Instance));

                    parameters.Add(IntegerParameter);
                    parameters.Add(LocalizedStringParameter);
                    parameters.Add(SetParameter);
                    parameters.Add(StringParameter);
                }
                else if (nodeTypeId == TYPE3)
                {
                    outputs.Add(new Output(Id <TConnector> .Parse("c3f67c87-a3fd-428d-90a2-90cb87906eb2"), allConnectorsDefinition, this, null, DummyRules.Instance));
                    parameters.Add(StringParameter);
                    parameters.Add(StringParameter2);
                }
                else
                {
                    Assert.Fail("Unexpected Id");
                }

                if (parameterData != null)
                {
                    foreach (var data in parameterData)
                    {
                        parameters.Where(p => p.Id == data.Guid).Single().TryDeserialiseValue(data.Value);
                    }
                }

                Connectors = outputs;
                Parameters = parameters;
            }