Пример #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);
 }