Esempio n. 1
0
            public void should_do_nothing_when_unexposed_if_not_exposed()
            {
                SimCapiMathExpression simCapiMathExpression = new SimCapiMathExpression("InitialValue");

                string exposedName = "exposeName";

                simCapiMathExpression.unexpose();

                Dictionary <string, SimCapiValue> _outGoingMap =
                    TestHelpers.getReferenceField <Dictionary <string, SimCapiValue> >(_transporter, "_outGoingMap");

                Assert.AreNotEqual(null, _outGoingMap);
                Assert.AreEqual(false, _outGoingMap.ContainsKey(exposedName));
            }
Esempio n. 2
0
            public void should_error_when_try_to_expose_twice()
            {
                SimCapiMathExpression simCapiMathExpression = new SimCapiMathExpression("InitialValue");

                string exposedName = "exposeName";

                simCapiMathExpression.expose(exposedName, true, true);

                Assert.Catch(
                    delegate()
                {
                    simCapiMathExpression.expose(exposedName, true, true);
                });
            }
Esempio n. 3
0
            public void should_call_on_change_delegate()
            {
                SimCapiMathExpression simCapiMathExpression = new SimCapiMathExpression("InitialValue");

                string exposedName = "exposeName";

                simCapiMathExpression.expose(exposedName, true, true);

                bool changeDelegateCalled = false;
                bool correctValue         = false;

                string newValue = "newValue";


                simCapiMathExpression.setChangeDelegate(
                    delegate(string value, ChangedBy changedBy)
                {
                    changeDelegateCalled = true;

                    if (value == newValue)
                    {
                        correctValue = true;
                    }
                });

                // Create the VALUE_CHANGE message
                SimCapiValue simCapiValue = new SimCapiValue(exposedName, SimCapiValueType.STRING, false, false, false, new StringData(newValue));
                Dictionary <string, SimCapiValue> valueDictionary = new Dictionary <string, SimCapiValue>();

                valueDictionary.Add(exposedName, simCapiValue);

                string valueChangedJson = SimCapiJsonMaker.create_VALUE_CHANGE(_transporter.getHandshake(), valueDictionary);

                _transporter.reciveJsonMessage(valueChangedJson);

                Assert.AreEqual(true, changeDelegateCalled);
                Assert.AreEqual(true, correctValue);
            }