예제 #1
0
        static void Main(string[] args)
        {
            var containerManager = new ContainerManager();
            var testObject       = new TestObject();

            containerManager.AddObjectToContainer("container1", testObject, "testobject");
            containerManager.AddMethodToContainer("container1", () => testObject.SetProperties(0, null, 0), "setTestValues");


            containerManager.AddObjectToContainer("container2", new TestObject(), "testobject2");
            containerManager.AddObjectToContainer("GameScreen",
                                                  new TestObject
            {
                IntValue    = 1234,
                StringValue = "This is background"
            }
                                                  , "BackgroundInstance");
            containerManager.AddObjectToContainer("GameScreen",
                                                  new TestObject
            {
                IntValue    = 5678,
                StringValue = "This is explosion"
            }
                                                  , "ExplosionInstance");



            using (var host = new OcularPlaneHost(containerManager, "localhost", 9999))
            {
                while (true)
                {
                    Thread.Sleep(100);
                }
            }
        }
예제 #2
0
        public void Can_Remove_Method_From_Container()
        {
            var test             = new TestClass();
            var containerManager = new ContainerManager();

            containerManager.AddMethodToContainer("container", () => test.SimpleMethod(0, null), "methodName");
            var method = containerManager.GetMethodsInContainer("container").First();

            containerManager.RemoveMethod(method.MethodId);
            var methods = containerManager.GetMethodsInContainer("container");

            methods.Length.Should().Be(0);
        }
예제 #3
0
        public void Cannot_Add_Method_With_Non_IConvertible_Parameter_Types()
        {
            var testClass        = new TestClass();
            var containerManager = new ContainerManager();

            try
            {
                containerManager.AddMethodToContainer("container", () => testClass.UnpassableMethodCall(null), "methodName");
                Assert.True(false, "Exception expected but none thrown");
            }
            catch (InvalidOperationException)
            {
            }
        }
예제 #4
0
        public void Can_Set_Enum_Parameter()
        {
            var testClass        = new TestClass();
            var containerManager = new ContainerManager();

            containerManager.AddMethodToContainer("container", () => testClass.SetEnumValue(0), "methodName");

            var method          = containerManager.GetMethodsInContainer("container").Single();
            var parameterValues = new Dictionary <string, string>
            {
                { "value", "Specified" },
            };

            containerManager.ExecuteMethod(method.MethodId, parameterValues);

            testClass.EnumProperty.Should().Be(TestClass.TestEnum.Specified);
        }
예제 #5
0
        public void Can_Execute_Static_Method()
        {
            var testClass        = new TestClass();
            var containerManager = new ContainerManager();

            containerManager.AddMethodToContainer("container", () => StaticTestMethod(0), "methodName");

            var method          = containerManager.GetMethodsInContainer("container").Single();
            var parameterValues = new Dictionary <string, string>
            {
                { "value", "1" },
            };

            containerManager.ExecuteMethod(method.MethodId, parameterValues);

            StaticInt.Should().Be(1);
        }
예제 #6
0
        public void Can_Execute_Method()
        {
            var testClass        = new TestClass();
            var containerManager = new ContainerManager();

            containerManager.AddMethodToContainer("container", () => testClass.SimpleMethod(0, null), "methodName");

            var method          = containerManager.GetMethodsInContainer("container").Single();
            var parameterValues = new Dictionary <string, string>
            {
                { "param1", "1" },
                { "param2", "two" }
            };

            containerManager.ExecuteMethod(method.MethodId, parameterValues);

            testClass.IntProperty.Should().Be(1);
            testClass.StringProperty.Should().Be("two");
        }
예제 #7
0
        public void Can_Add_Methods_To_Container_Manager()
        {
            var testClass = new TestClass();

            var containerManager = new ContainerManager();

            containerManager.AddMethodToContainer("container", () => testClass.SimpleMethod(0, null), "methodName");

            var methods = containerManager.GetMethodsInContainer("container");

            methods.Should().NotBeNull();
            methods.Length.Should().Be(1);
            methods[0].Should().NotBeNull();
            methods[0].MethodId.Should().NotBeEmpty();
            methods[0].Name.Should().Be("methodName");
            methods[0].Parameters.Should().NotBeNull();
            methods[0].Parameters.Length.Should().Be(2);
            methods[0].Parameters[0].ParameterName.Should().Be("param1");
            methods[0].Parameters[0].TypeName.Should().Be(typeof(int).FullName);
            methods[0].Parameters[1].ParameterName.Should().Be("param2");
            methods[0].Parameters[1].TypeName.Should().Be(typeof(string).FullName);
        }