Example #1
0
        /// <summary>
        /// Proxy a namespace
        /// </summary>
        /// <param name="block"></param>
        /// <param name="url"></param>
        /// <param name="useDataContext"></param>
        /// <param name="serializer"></param>
        /// <param name="namingConvention"></param>
        /// <param name="namespaces"></param>
        public static void ProxyNamespace(this IExportRegistrationBlock block,
                                          string url                   = null,
                                          bool useDataContext          = false,
                                          IClientSerializer serializer = null,
                                          INamingConventionService namingConvention = null,
                                          params string[] namespaces)
        {
            RegisterExports(block);

            SetupProxyInfo(block, url, useDataContext, serializer, namingConvention, namespaces);
        }
Example #2
0
        private static void SetupProxyInfo(IExportRegistrationBlock block,
                                           string url,
                                           bool useDataContext,
                                           IClientSerializer serializer,
                                           INamingConventionService namingConvention,
                                           string[] namespaces)
        {
            var config = new ProxyNamespaceConfig
            {
                Url              = url,
                UseDataContext   = useDataContext,
                Namespaces       = namespaces,
                Serializer       = serializer,
                NamingConvention = namingConvention
            };

            block.AddMissingExportStrategyProvider(new ProxyStrategyProvider(config));
        }
        public async Task TaskWithValueInterfaceReturnTest(ServiceImplementationGenerator implementationGenerator, IClientSerializer clientSerializer, Fixture fixture)
        {
            var request = new ImplementationRequest
            {
                InterfaceType         = typeof(ITestInterface),
                SingleParameterToBody = true,
                DefaultSerializer     = clientSerializer
            };

            var type = implementationGenerator.GenerateImplementationForInterface(request);

            var testInterface = (ITestInterface)fixture.Locate(type);

            var a = 5;
            var b = 5;

            fixture.Locate <IRpcExecutionService>().ExecuteMethodWithValue <int>(Arg.Any <RpcExecuteInformation>(),
                                                                                 Arg.Any <string>(), Arg.Any <object>(), Arg.Any <CancellationToken?>()).Returns(callInfo =>
            {
                var value = callInfo.ArgAt <object>(2);

                var properties = ReflectionService.GetPropertiesFromObject(value);

                var aValue = (int)properties[nameof(a)];
                var bValue = (int)properties[nameof(b)];

                return(aValue + bValue);
            });


            var value = await testInterface.Add(5, 5);


            Assert.Equal(a + b, value);
        }