示例#1
0
        public void ExtractOperationIgnored()
        {
            var contract = ContractDescription.GetContract(typeof(IIgnored));

            var operations = ContractReader.ExtractCancellableOperations(contract);

            CollectionAssert.IsEmpty(operations.Keys);
        }
示例#2
0
        public void ValidateFail(Type contractType)
        {
            var contract = ContractDescription.GetContract(contractType);

            var ex = Assert.Throws <NotSupportedException>(() => ContractReader.Validate(contract));

            Console.WriteLine(ex.Message);
        }
示例#3
0
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            var operationByName = ContractReader.ExtractCancellableOperations(endpoint.Contract);

            if (operationByName.Count > 0)
            {
                var operationManager = ServiceProvider.Resolve <IClientOperationManager>();
                var inspector        = new ClientOperationParameterInspector(operationManager, operationByName);

                foreach (var operation in clientRuntime.ClientOperations)
                {
                    if (operationByName.ContainsKey(operation.Name))
                    {
                        operation.ParameterInspectors.Add(inspector);
                    }
                }
            }
        }
示例#4
0
        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            var operationByName = ContractReader.ExtractCancellableOperations(endpoint.Contract);

            if (operationByName.Count > 0)
            {
                var operationManager = ServiceProvider.Resolve <IDispatchOperationManager>();
                var inspector        = new DispatchOperationParameterInspector(operationManager, operationByName);

                foreach (var operation in endpointDispatcher.DispatchRuntime.Operations)
                {
                    if (operationByName.ContainsKey(operation.Name))
                    {
                        operation.ParameterInspectors.Add(inspector);
                    }
                }
            }
        }
示例#5
0
        public void ExtractOperationSupported()
        {
            var contract   = ContractDescription.GetContract(typeof(ISupported));
            var operations = ContractReader.ExtractCancellableOperations(contract);

            CollectionAssert.AreEqual(
                new[]
            {
                nameof(ISupported.Method),
                nameof(ISupported.MethodTokenProxy),
                nameof(ISupported.MethodNullableTokenProxy),
                nameof(ISupported.MethodToken),
                nameof(ISupported.MethodNullableToken)
            },
                operations.Keys);

            var operation = operations[nameof(ISupported.Method)];

            Assert.AreEqual(1, operation.TokenArgIndex);
            Assert.AreEqual("ISupported.Method", operation.FullName);

            operation = operations[nameof(ISupported.MethodTokenProxy)];
            Assert.AreEqual(0, operation.TokenArgIndex);
            Assert.AreEqual("ISupported.MethodTokenProxy", operation.FullName);

            operation = operations[nameof(ISupported.MethodNullableTokenProxy)];
            Assert.AreEqual(0, operation.TokenArgIndex);
            Assert.AreEqual("ISupported.MethodNullableTokenProxy", operation.FullName);

            operation = operations[nameof(ISupported.MethodToken)];
            Assert.AreEqual(0, operation.TokenArgIndex);
            Assert.AreEqual("ISupported.MethodToken", operation.FullName);

            operation = operations[nameof(ISupported.MethodNullableToken)];
            Assert.AreEqual(0, operation.TokenArgIndex);
            Assert.AreEqual("ISupported.MethodNullableToken", operation.FullName);
        }
示例#6
0
        public void ValidatePass(Type contractType)
        {
            var contract = ContractDescription.GetContract(contractType);

            ContractReader.Validate(contract);
        }
示例#7
0
 public void Validate(ServiceEndpoint endpoint)
 {
     ContractReader.Validate(endpoint.Contract);
 }