Exemple #1
0
        protected void AddMethodIfNecessary(ConversationalMetaInfoHolder holder, MethodInfo method, IPersistenceConversationInfo info)
        {
            IPersistenceConversationInfo toAdd = null;

            if (info != null)
            {
                if (!info.Exclude)
                {
                    toAdd = info;
                }
            }
            else
            {
                if (holder.Setting.MethodsIncludeMode == MethodsIncludeMode.Implicit)
                {
                    toAdd = new PersistenceConversationAttribute();
                }
            }
            if (toAdd != null && toAdd.ConversationEndMode == EndMode.Unspecified)
            {
                toAdd.ConversationEndMode = holder.Setting.DefaultEndMode;
            }
            if (toAdd != null)
            {
                holder.AddMethodInfo(method, toAdd);
            }
        }
		protected void AddMethodIfNecessary(ConversationalMetaInfoHolder holder, MethodInfo method, IPersistenceConversationInfo info)
		{
			IPersistenceConversationInfo toAdd = null;
			if (info != null)
			{
				if (!info.Exclude)
				{
					toAdd = info;
				}
			}
			else
			{
				if (holder.Setting.MethodsIncludeMode == MethodsIncludeMode.Implicit)
				{
					toAdd = new PersistenceConversationAttribute();
				}
			}
			if (toAdd != null && toAdd.ConversationEndMode == EndMode.Unspecified)
			{
				toAdd.ConversationEndMode = holder.Setting.DefaultEndMode;
			}
			if(toAdd != null)
			{
				holder.AddMethodInfo(method, toAdd);
			}
		}
        public void ShouldWorkWithDefaultValues()
        {
            // This test is useful to check future Breaking-changes
            var a = new PersistenceConversationAttribute();

            Assert.That(a.ConversationEndMode, Is.EqualTo(EndMode.Unspecified));
            Assert.That(a.Exclude, Is.False);
        }
        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 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);
        }