コード例 #1
0
 public void SetUp()
 {
     try
     {
         _tester = AssemblyInitialize.ResolutionRoot.GetServiceTester <CalculatorServiceHost>();
         _serviceProxyProvider = _tester.GetServiceProxyProvider("CalculatorService");
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #2
0
ファイル: ServiceTester.cs プロジェクト: xzoth/microdot
        /// <summary>
        /// GetObject a ServiceProxy that is configured to call the service under test. Both the port and the hostname of
        /// the provided ServiceProxy is changed to match those of the service which was started by the ServiceTester.
        /// </summary>
        /// <param name="timeout">Optional. The timeout for ServiceProxy calls.</param>
        /// <typeparam name="TServiceInterface"></typeparam>
        /// <returns>An ServiceProxy instance of <see cref="TServiceInterface"/>.</returns>
        public virtual TServiceInterface GetServiceProxy <TServiceInterface>(TimeSpan?timeout = null)
        {
            var factory = ResolutionRoot.Get <Func <string, Func <string, ReachabilityChecker, IServiceDiscovery>, IServiceProxyProvider> >();

            var provider = new ServiceProxyProvider <TServiceInterface>(serviceName => factory(serviceName, (serName, checker) => new LocalhostServiceDiscovery()));

            provider.DefaultPort = BasePort;
            if (timeout != null)
            {
                provider.InnerProvider.SetHttpTimeout(timeout.Value);
            }

            return(provider.Client);
        }
コード例 #3
0
ファイル: ServiceTester.cs プロジェクト: xzoth/microdot
        /// <summary>
        /// GetObject a ServiceProxy with caching  that is configured to call the service under test. Both the port and the hostname of
        /// the provided ServiceProxy is changed to match those of the service which was started by the ServiceTester.
        /// </summary>
        /// <param name="timeout">Optional. The timeout for ServiceProxy calls.</param>
        /// <typeparam name="TServiceInterface"></typeparam>
        /// <returns>An ServiceProxy with caching <see cref="TServiceInterface"/>.</returns>
        public virtual TServiceInterface GetServiceProxyWithCaching <TServiceInterface>(TimeSpan?timeout = null)
        {
            var factory = ResolutionRoot
                          .Get <Func <string, Func <string, ReachabilityChecker, IServiceDiscovery>, IServiceProxyProvider> >();
            var provider = new ServiceProxyProvider <TServiceInterface>(serviceName => factory(serviceName, (serName, checker) => new LocalhostServiceDiscovery()));

            provider.DefaultPort = BasePort;
            if (timeout != null)
            {
                provider.InnerProvider.SetHttpTimeout(timeout.Value);
            }
            if (ResolutionRoot.Get <IMetadataProvider>().HasCachedMethods(typeof(TServiceInterface)))
            {
                var cachingProxy = ResolutionRoot.Get <CachingProxyProvider <TServiceInterface> >(
                    new ConstructorArgument("dataSource", provider.Client),
                    new ConstructorArgument("serviceName", (string)null));

                return(cachingProxy.Proxy);
            }
            return(provider.Client);
        }