コード例 #1
0
 public void TestNoReturnValue()
 {
     MockSpawnController spawnController = new MockSpawnController();
     Proxy.ProxyBuilder proxyBuilder = new Proxy.ProxyBuilder(new JsonSerializer(), spawnController, new MessageTypeBuilder(), new MessageTypeDefinitionBuilder());
     var proxy = proxyBuilder.BuildProxy<IMockType>();
     proxy.DoSomethingVoid(1);
 }
コード例 #2
0
        public void TestReturnValue()
        {
            MockSpawnController spawnController = new MockSpawnController();
            Proxy.ProxyBuilder proxyBuilder = new Proxy.ProxyBuilder(new JsonSerializer(), spawnController, new MessageTypeBuilder(), new MessageTypeDefinitionBuilder());
            var proxy = proxyBuilder.BuildProxy<IMockType>();
            var result = proxy.DoSomethingInt(1);

            Assert.AreEqual(3, result);
        }
コード例 #3
0
        public void TestSimpleProxy()
        {
            MockSpawnController spawnController = new MockSpawnController();
            Proxy.ProxyBuilder proxyBuilder = new Proxy.ProxyBuilder(new JsonSerializer(), spawnController, new MessageTypeBuilder(), new MessageTypeDefinitionBuilder());
            var proxy = proxyBuilder.BuildProxy<IMockType>();
            proxy.DoSomethingPrimitiveAndObjectParameters(1, 2, "a string", new MockObject { AString = "another string", ANumber = 3 });

            Assert.AreEqual(4, spawnController.messageTypeDefinition.Arguments.Length);
            Assert.AreEqual(typeof(int).FullName, spawnController.messageTypeDefinition.Arguments[0].Type);
            Assert.AreEqual(typeof(int).FullName, spawnController.messageTypeDefinition.Arguments[1].Type);
            Assert.AreEqual(typeof(string).FullName, spawnController.messageTypeDefinition.Arguments[2].Type);
            Assert.AreEqual(typeof(MockObject).FullName, spawnController.messageTypeDefinition.Arguments[3].Type);
            //Assert.AreEqual("{\"one\":1,\"two\":2,\"three\":\"a string\",\"mockObject\":{\"AString\":\"another string\",\"ANumber\":3}}", Encoding.UTF8.GetString(spawnController.arguments));
        }