예제 #1
0
        public void Should_create_an_overarching_type()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <OverarchingArgument>();

            ObjectInfo[] objectInfos = MessageInfoCache.GetMessageObjectInfo(messageInfo);

            ObjectInfoContractCache.AddContracts(objectInfos);

            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("CommandId"));
            Assert.That(properties[0].PropertyType, Is.EqualTo(typeof(Guid)));
            Assert.That(properties[1].Name, Is.EqualTo("Argument"));

            properties = properties[1].PropertyType.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)));
        }
예제 #2
0
        public void Should_get_info_for_an_activity()
        {
            var argumentInfo = MessageInfoCache.GetMessageInfo <TestArguments>();
            var logInfo      = MessageInfoCache.GetMessageInfo <TestLog>();
            var objectInfos  = MessageInfoCache.GetMessageObjectInfo(argumentInfo, logInfo);

            Assert.That(objectInfos.Length, Is.EqualTo(2));
        }
예제 #3
0
        public void Should_work()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <SimpleArgument>();

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

            Assert.That(messageInfo.MessageTypes[0], Is.EqualTo(MessageUrn.ForTypeString <SimpleArgument>()));
        }
        public ServiceEndpointMessageClientCache(IServiceEndpointClientCache endpointClientCache)
        {
            _endpointClientCache = endpointClientCache;
            _cache = new GreenCache <ServiceClientContext>(ServiceInstanceClientCacheDefaults.Settings);
            _index = _cache.AddIndex("clientId", x => x.ClientId);

            MessageInfo = MessageInfoCache.GetMessageInfo <TMessage>();

            endpointClientCache.Connect(this);
        }
예제 #5
0
        public void Should_support_looped_property_types_an_have_object_info()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <ExceptionInfo>();

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

            ObjectInfo[] objectInfos = MessageInfoCache.GetMessageObjectInfo(messageInfo);

            Assert.That(objectInfos, Is.Not.Null);
            Assert.That(objectInfos.Length, Is.EqualTo(1));
            Assert.That(objectInfos[0].ObjectType, Is.EqualTo(MessageUrn.ForTypeString <ExceptionInfo>()));
        }
예제 #6
0
        public void Should_support_message_property_types()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <OverarchingArgument>();

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

            Assert.That(messageInfo.MessageTypes[0], Is.EqualTo(MessageUrn.ForTypeString <OverarchingArgument>()));

            Assert.That(messageInfo.Properties, Is.Not.Null);
            Assert.That(messageInfo.Properties.Length, Is.EqualTo(2));
            Assert.That(messageInfo.Properties[1].Kind, Is.EqualTo(PropertyKind.Object));
            Assert.That(messageInfo.Properties[1].PropertyType, Is.EqualTo(MessageUrn.ForTypeString <SimpleArgument>()));
        }
예제 #7
0
        public void Should_support_object_property_types_an_have_object_info()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <NestedArgument>();

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

            ObjectInfo[] objectInfos = MessageInfoCache.GetMessageObjectInfo(messageInfo);

            Assert.That(objectInfos, Is.Not.Null);
            Assert.That(objectInfos.Length, Is.EqualTo(4));
            Assert.That(objectInfos[0].ObjectType, Is.EqualTo(MessageUrn.ForTypeString <SimpleArgument>()));
            Assert.That(objectInfos[1].ObjectType, Is.EqualTo(MessageUrn.ForTypeString <OverarchingArgument>()));
            Assert.That(objectInfos[2].ObjectType, Is.EqualTo(MessageUrn.ForTypeString <DictionaryArgument>()));
            Assert.That(objectInfos[3].ObjectType, Is.EqualTo(MessageUrn.ForTypeString <NestedArgument>()));
        }
예제 #8
0
        public void Should_support_array_property_types()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <ArrayArgument>();

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

            Assert.That(messageInfo.MessageTypes[0], Is.EqualTo(MessageUrn.ForTypeString <ArrayArgument>()));

            Assert.That(messageInfo.Properties, Is.Not.Null);
            Assert.That(messageInfo.Properties.Length, Is.EqualTo(3));
            Assert.That(messageInfo.Properties[0].Kind.HasFlag(PropertyKind.Array), Is.True);
            Assert.That(messageInfo.Properties[0].PropertyType, Is.EqualTo(TypeMetadataCache <int> .ShortName));
            Assert.That(messageInfo.Properties[1].Kind.HasFlag(PropertyKind.Array), Is.True);
            Assert.That(messageInfo.Properties[1].PropertyType, Is.EqualTo(TypeMetadataCache <string> .ShortName));
            Assert.That(messageInfo.Properties[2].Kind.HasFlag(PropertyKind.Array), Is.True);
            Assert.That(messageInfo.Properties[2].PropertyType, Is.EqualTo(MessageUrn.ForTypeString <SimpleArgument>()));
        }
예제 #9
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)));
        }
예제 #10
0
        public void Should_support_dictionary_property_types()
        {
            var messageInfo = MessageInfoCache.GetMessageInfo <DictionaryArgument>();

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

            Assert.That(messageInfo.MessageTypes[0], Is.EqualTo(MessageUrn.ForTypeString <DictionaryArgument>()));

            Assert.That(messageInfo.Properties, Is.Not.Null);
            Assert.That(messageInfo.Properties.Length, Is.EqualTo(3));
            Assert.That(messageInfo.Properties[0].Kind.HasFlag(PropertyKind.Dictionary), Is.True);
            Assert.That(messageInfo.Properties[0].KeyType, Is.EqualTo(TypeMetadataCache <string> .ShortName));
            Assert.That(messageInfo.Properties[0].PropertyType, Is.EqualTo(TypeMetadataCache <object> .ShortName));
            Assert.That(messageInfo.Properties[1].Kind.HasFlag(PropertyKind.Dictionary), Is.True);
            Assert.That(messageInfo.Properties[1].KeyType, Is.EqualTo(TypeMetadataCache <int> .ShortName));
            Assert.That(messageInfo.Properties[1].PropertyType, Is.EqualTo(TypeMetadataCache <string> .ShortName));
            Assert.That(messageInfo.Properties[2].Kind.HasFlag(PropertyKind.Dictionary), Is.True);
            Assert.That(messageInfo.Properties[2].KeyType, Is.EqualTo(TypeMetadataCache <string> .ShortName));
            Assert.That(messageInfo.Properties[2].PropertyType, Is.EqualTo(MessageUrn.ForTypeString <OverarchingArgument>()));
        }