public void GetConversationInfoFor()
        {
            ConversationalMetaInfoHolder classDef = CreateNewSampleDef();
            MethodInfo methodInfo = Reflector.MethodInfo <Sample>(o => o.NoPersistentMethod());

            classDef.GetConversationInfoFor(methodInfo).Should("return null when method is unknow").Be.Null();
        }
Пример #2
0
        public void NotAllowDuplication()
        {
            var settings    = new PersistenceConversationalAttribute();
            var classDef    = new ConversationalMetaInfoHolder(typeof(Sample), settings);
            var classDefDup = new ConversationalMetaInfoHolder(typeof(Sample), settings);
            var store       = new ConversationalMetaInfoStore();

            store.AddMetadata(classDef);
            Assert.Throws <ArgumentException>(() => store.AddMetadata(classDefDup));
        }
        protected override void BuildMetaInfoFromType(ConversationalMetaInfoHolder metaInfo, System.Type implementation)
        {
            MethodInfo[] methods = implementation.GetMethods(MethodBindingFlags);

            foreach (MethodInfo method in methods)
            {
                var mi = MetaInfoInspector.GetMethodInfo(method);
                AddMethodIfNecessary(metaInfo, method, mi);
            }
        }
Пример #4
0
        public void ShouldWork()
        {
            var settings = new PersistenceConversationalAttribute();
            var classDef = new ConversationalMetaInfoHolder(typeof(Sample), settings);
            var store    = new ConversationalMetaInfoStore();

            store.AddMetadata(classDef);
            store.MetaData.Should().Not.Be.Empty();
            store.MetaData.Should().Contain(classDef);
            store.GetMetadataFor(typeof(Sample)).Should().Be.SameInstanceAs(classDef);
        }
        public void AddMethodInfoShouldBeProtected()
        {
            ConversationalMetaInfoHolder classDef = CreateNewSampleDef();
            MethodInfo methodInfo    = Reflector.MethodInfo <Sample>(o => o.NoPersistentMethod());
            var        methodSetting = new PersistenceConversationAttribute();

            Assert.Throws <ArgumentNullException>(() => classDef.AddMethodInfo(methodInfo, null))
            .ParamName.Should().Be.EqualTo("persistenceConversationInfo");
            Assert.Throws <ArgumentNullException>(() => classDef.AddMethodInfo(null, methodSetting))
            .ParamName.Should().Be.EqualTo("methodInfo");
        }
        public void PropertiesDefault()
        {
            var settings = new PersistenceConversationalAttribute();
            var classDef = new ConversationalMetaInfoHolder(typeof(Sample), settings);

            classDef.ConversationalClass.Should().Be.EqualTo(typeof(Sample));
            classDef.Setting.Should().Be.SameInstanceAs(settings);
            classDef.Methods.Should().Be.Empty();

            Assert.That(!classDef.Contains(Reflector.MethodInfo <object>(o => o.GetHashCode())));
        }
        public void AddMethodInfoShouldWork()
        {
            ConversationalMetaInfoHolder classDef = CreateNewSampleDef();
            var        methodSetting = new PersistenceConversationAttribute();
            MethodInfo methodInfo    = Reflector.MethodInfo <Sample>(o => o.PersistentMethod());

            classDef.AddMethodInfo(methodInfo, methodSetting);
            classDef.Methods.Count().Should().Be.EqualTo(1);
            classDef.Methods.Should().Contain(methodInfo);
            classDef.Contains(methodInfo).Should().Be.True();
            classDef.GetConversationInfoFor(methodInfo).Should().Be.SameInstanceAs(methodSetting);
        }