コード例 #1
0
    public static void Default_Ctor_Initializes_Correctly()
    {
        CallbackBehaviorAttribute cba = new CallbackBehaviorAttribute();

        Assert.True(cba.AutomaticSessionShutdown, "AutomaticSessionShutdown should have been true");
        Assert.True(cba.UseSynchronizationContext, "UseSynchronizationContext should have been true");
    }
コード例 #2
0
    public static void AutomaticSessionShutdown_Property_Is_Settable(bool value)
    {
        CallbackBehaviorAttribute cba = new CallbackBehaviorAttribute();

        cba.AutomaticSessionShutdown = value;
        Assert.Equal(value, cba.AutomaticSessionShutdown);
    }
コード例 #3
0
    public static void UseSynchronizationContext_Property_Is_Settable(bool value)
    {
        CallbackBehaviorAttribute cba = new CallbackBehaviorAttribute();

        cba.UseSynchronizationContext = value;
        Assert.Equal(value, cba.UseSynchronizationContext);
    }
コード例 #4
0
        public DiscoveryCallbackBehavior()
        {
            this.innerCallbackBehavior = new CallbackBehaviorAttribute();

            this.innerCallbackBehavior.ConcurrencyMode           = ConcurrencyMode.Multiple;
            this.innerCallbackBehavior.UseSynchronizationContext = false;
        }
コード例 #5
0
        public DiscoveryCallbackBehavior()
        {
            this.innerCallbackBehavior = new CallbackBehaviorAttribute();

            this.innerCallbackBehavior.ConcurrencyMode = ConcurrencyMode.Multiple;
            this.innerCallbackBehavior.UseSynchronizationContext = false;
        }
コード例 #6
0
    public static void ConcurrencyMode_Property_Is_Settable(ConcurrencyMode value)
    {
        CallbackBehaviorAttribute cba = new CallbackBehaviorAttribute();

        cba.ConcurrencyMode = value;
        Assert.Equal(value, cba.ConcurrencyMode);
    }
コード例 #7
0
        public void ApplyDispatchBehavior()
        {
            // It cannot be applied to service endpoint dispatcher.
            IEndpointBehavior eb = new CallbackBehaviorAttribute()
            {
                ConcurrencyMode = ConcurrencyMode.Multiple, ValidateMustUnderstand = false
            };
            var cd = ContractDescription.GetContract(typeof(IFoo));
            var se = new ServiceEndpoint(cd);
            var ed = new EndpointDispatcher(new EndpointAddress("http://localhost:" + NetworkHelpers.FindFreePort()), "IFoo", "urn:foo");

            eb.ApplyDispatchBehavior(se, ed);
        }
コード例 #8
0
        public void AddBindingParameters()
        {
            IEndpointBehavior eb = new CallbackBehaviorAttribute();
            var cd = ContractDescription.GetContract(typeof(IFoo));
            var se = new ServiceEndpoint(cd);

            Assert.AreEqual(0, se.Behaviors.Count, "#1");
            var pc = new BindingParameterCollection();

            eb.AddBindingParameters(se, pc);
            Assert.AreEqual(0, pc.Count, "#2");
            Assert.AreEqual(0, se.Behaviors.Count, "#3");
        }
コード例 #9
0
        public void ApplyClientBehaviorNonDuplex()
        {
            // It must be applied to duplex callback runtime
            IEndpointBehavior eb = new CallbackBehaviorAttribute()
            {
                ConcurrencyMode = ConcurrencyMode.Multiple, ValidateMustUnderstand = false
            };
            var cd = ContractDescription.GetContract(typeof(IFoo));
            var se = new ServiceEndpoint(cd);
            var ed = new EndpointDispatcher(new EndpointAddress("http://localhost:" + NetworkHelpers.FindFreePort()), "IFoo", "urn:foo");
            var cr = ed.DispatchRuntime.CallbackClientRuntime;

            eb.ApplyClientBehavior(se, cr);
        }
コード例 #10
0
        public void DefaultValues()
        {
            var c = new CallbackBehaviorAttribute();

            Assert.IsTrue(c.AutomaticSessionShutdown, "#1");
            Assert.AreEqual(ConcurrencyMode.Single, c.ConcurrencyMode, "#2");
            Assert.IsFalse(c.IgnoreExtensionDataObject, "#3");
            Assert.IsFalse(c.IncludeExceptionDetailInFaults, "#4");
            Assert.AreEqual(0x10000, c.MaxItemsInObjectGraph, "#5");
            Assert.AreEqual(IsolationLevel.Unspecified, c.TransactionIsolationLevel, "#6");
            Assert.IsNull(c.TransactionTimeout, "#7");
            Assert.IsTrue(c.UseSynchronizationContext, "#8");
            Assert.IsTrue(c.ValidateMustUnderstand, "#9");
        }
コード例 #11
0
 private void ValidateCallbackBehaviorAttributeWithNoScopeRequired(ServiceEndpoint endpoint)
 {
     if (!this.HasTransactedOperations(endpoint))
     {
         CallbackBehaviorAttribute attribute = endpoint.Behaviors.Find <CallbackBehaviorAttribute>();
         if (attribute != null)
         {
             if (attribute.TransactionTimeoutSet)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionTransactionTimeoutNeedsScope", new object[] { endpoint.Contract.Name })));
             }
             if (attribute.IsolationLevelSet)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionIsolationLevelNeedsScope", new object[] { endpoint.Contract.Name })));
             }
         }
     }
 }
        void ValidateCallbackBehaviorAttributeWithNoScopeRequired(ServiceEndpoint endpoint)
        {
            // If the endpoint has no operations with TransactionScopeRequired=true, disallow any
            // transaction-related properties on the CallbackBehaviorAttribute
            if (!HasTransactedOperations(endpoint))
            {
                CallbackBehaviorAttribute attribute = endpoint.Behaviors.Find <CallbackBehaviorAttribute>();
                if (attribute != null)
                {
                    if (attribute.TransactionTimeoutSet)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                      SR.GetString(SR.SFxTransactionTransactionTimeoutNeedsScope, endpoint.Contract.Name)));
                    }

                    if (attribute.IsolationLevelSet)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                      SR.GetString(SR.SFxTransactionIsolationLevelNeedsScope, endpoint.Contract.Name)));
                    }
                }
            }
        }