Beispiel #1
0
        public void Should_create_a_simple_type()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <SimpleArgument>();

            var contract = ObjectInfoContractCache.GetOrAddContract(messageInfo);

            var factory = ContractCache.GetMessageFactory(contract);

            var message = factory.Create();

            var properties = message.GetType().GetProperties();

            Assert.That(properties.Length, Is.EqualTo(2));
            Assert.That(properties[0].Name, Is.EqualTo("Name"));
            Assert.That(properties[0].PropertyType, Is.EqualTo(typeof(string)));
            Assert.That(properties[1].Name, Is.EqualTo("Age"));
            Assert.That(properties[1].PropertyType, Is.EqualTo(typeof(int)));
        }
        public void Should_create_a_dynamic_type()
        {
            var contract = ContractCache <SimpleArgument> .Contracts.First();

            var messageFactory = ContractCache.GetMessageFactory(contract);

            var message = messageFactory.Create();

            Assert.That(message, Is.Not.Null);

            var messageType = message.GetType();

            TestContext.WriteLine(messageType.FullName);
            TestContext.WriteLine(messageType.Assembly.FullName);


            PropertyInfo[] properties = messageType.GetProperties();
            Assert.That(properties.Length, Is.EqualTo(2));
        }