Ejemplo n.º 1
0
            public void should_error_when_try_to_expose_twice()
            {
                SimCapiPointArray simCapiPointArray = new SimCapiPointArray();

                simCapiPointArray.getPointList().Add(new Vector2(1, 2));
                simCapiPointArray.getPointList().Add(new Vector2(3, 4));
                simCapiPointArray.getPointList().Add(new Vector2(5, 6));

                string exposedName = "exposeName";

                simCapiPointArray.expose(exposedName, true, true);

                Assert.Catch(
                    delegate()
                {
                    simCapiPointArray.expose(exposedName, true, true);
                });
            }
Ejemplo n.º 2
0
            public void should_expose_value()
            {
                SimCapiPointArray simCapiPointArray = new SimCapiPointArray();

                simCapiPointArray.getPointList().Add(new Vector2(1, 2));
                simCapiPointArray.getPointList().Add(new Vector2(3, 4));
                simCapiPointArray.getPointList().Add(new Vector2(5, 6));

                string exposedName = "exposeName";

                simCapiPointArray.expose(exposedName, true, true);

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

                Assert.AreNotEqual(null, _outGoingMap);
                Assert.AreEqual(true, _outGoingMap.ContainsKey(exposedName));
            }
Ejemplo n.º 3
0
            public void should_call_on_change_delegate()
            {
                SimCapiPointArray simCapiPointArray = new SimCapiPointArray();

                simCapiPointArray.getPointList().Add(new Vector2(1, 2));
                simCapiPointArray.getPointList().Add(new Vector2(3, 4));
                simCapiPointArray.getPointList().Add(new Vector2(5, 6));

                string exposedName = "exposeName";

                simCapiPointArray.expose(exposedName, true, true);

                bool changeDelegateCalled = false;
                bool correctValue         = false;


                simCapiPointArray.setChangeDelegate(
                    delegate(Vector2[] value, ChangedBy changedBy)
                {
                    changeDelegateCalled = true;

                    if (value.Length == 3 &&
                        value[0] == new Vector2(6, 5) &&
                        value[1] == new Vector2(4, 3) &&
                        value[2] == new Vector2(2, 1))
                    {
                        correctValue = true;
                    }
                });

                // Create the VALUE_CHANGE message
                SimCapiValue simCapiValue = new SimCapiValue(exposedName, SimCapiValueType.ARRAY, false, false, false, new ArrayData(new[] { "(6;5)", "(4;3)", "(2;1)" }));
                Dictionary <string, SimCapiValue> valueDictionary = new Dictionary <string, SimCapiValue>();

                valueDictionary.Add(exposedName, simCapiValue);

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

                _transporter.reciveJsonMessage(valueChangedJson);

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