Example #1
0
        public TestContext(bool handMadeProxy, bool startPlugin, CatchExceptionGeneration catchExceptionsForRealProxy)
        {
            PluginHost     = new PluginHost(catchExceptionsForRealProxy);
            RealPlugin     = new ChoucroutePlugin();
            ConsumerPlugin = new ConsumerPlugin(this);

            PluginHost.PluginCreator           = key => key == PluginPluginId ? (IPlugin)RealPlugin : ConsumerPlugin;
            PluginHost.ServiceReferencesBinder = newPluginsLoaded => { };

            if (handMadeProxy)
            {
                ServiceHost.SetManualProxy(typeof(IChoucrouteService), IChoucrouteServiceHandMadeProxy.CreateProxy());
            }

            // The proxy is itself a IChoucrouteService.
            Assert.That(Service is IChoucrouteService);
            Assert.That(Service is ServiceProxyBase);
            // We check the Running attribute.
            Assert.That(Service.Status == RunningStatus.Disabled);

            Assert.That(PluginProxy == null);

            if (startPlugin)
            {
                PluginHost.Execute(ReadOnlyListEmpty <IPluginInfo> .Empty, ReadOnlyListEmpty <IPluginInfo> .Empty, new[] { PluginPluginId });
                Assert.That(PluginProxy.Status == RunningStatus.Started);
                Assert.That(Service.Status == RunningStatus.Started);
            }
        }
Example #2
0
 internal PluginHost( CatchExceptionGeneration catchMode )
 {
     _plugins = new Dictionary<IPluginInfo, PluginProxy>();
     _loadedPlugins = new Dictionary<Guid, PluginProxy>();
     _loadedPluginsEx = new ReadOnlyCollectionOnICollection<PluginProxy>( _loadedPlugins.Values );
     _serviceHost = new ServiceHost( catchMode );
     _newlyLoadedPlugins = new List<PluginProxy>();
 }
Example #3
0
 internal PluginHost(CatchExceptionGeneration catchMode)
 {
     _plugins            = new Dictionary <IPluginInfo, PluginProxy>();
     _loadedPlugins      = new Dictionary <Guid, PluginProxy>();
     _loadedPluginsEx    = new ReadOnlyCollectionOnICollection <PluginProxy>(_loadedPlugins.Values);
     _serviceHost        = new ServiceHost(catchMode);
     _newlyLoadedPlugins = new List <PluginProxy>();
 }
        public DefaultProxyDefinition( Type typeInterface, CatchExceptionGeneration errorCatch )
		{
			if( !typeInterface.IsInterface )
			{
				throw new ArgumentException( "Must be an interface.", "typeInterface" );
			}
			_typeInterface = typeInterface;
            _errorCatch = errorCatch;
            _isDynamicService = typeof( IDynamicService ).IsAssignableFrom( typeInterface );
        }
Example #5
0
 public DefaultProxyDefinition(Type typeInterface, CatchExceptionGeneration errorCatch)
 {
     if (!typeInterface.IsInterface)
     {
         throw new ArgumentException("Must be an interface.", "typeInterface");
     }
     _typeInterface    = typeInterface;
     _errorCatch       = errorCatch;
     _isDynamicService = typeof(IDynamicService).IsAssignableFrom(typeInterface);
 }
Example #6
0
        public ServiceHost(CatchExceptionGeneration catchMode)
        {
            _eventSender          = this;
            _catchMode            = catchMode;
            _proxies              = new Dictionary <Type, ServiceProxyBase>();
            _currentDepth         = 0;
            _defaultConfiguration = new SimpleServiceHostConfiguration();
            _configurations       = new List <IServiceHostConfiguration>();
            _configurations.Add(_defaultConfiguration);

            _untrackedErrors = new List <ILogErrorCaught>();
            UntrackedErrors  = new ReadOnlyListOnIList <ILogErrorCaught>(_untrackedErrors);
        }
Example #7
0
        public TestContext( bool handMadeProxy, bool startPlugin, CatchExceptionGeneration catchExceptionsForRealProxy )
        {
            PluginHost = new PluginHost( catchExceptionsForRealProxy );
            RealPlugin = new ChoucroutePlugin();
            ConsumerPlugin = new ConsumerPlugin( this );

            PluginHost.PluginCreator = key => key == PluginPluginId ? (IPlugin)RealPlugin : ConsumerPlugin;
            PluginHost.ServiceReferencesBinder = newPluginsLoaded => { };
            
            if( handMadeProxy )
            {
                ServiceHost.SetManualProxy( typeof(IChoucrouteService), IChoucrouteServiceHandMadeProxy.CreateProxy() );
            }

            // The proxy is itself a IChoucrouteService.
            Assert.That( Service is IChoucrouteService );
            Assert.That( Service is ServiceProxyBase );
            // We check the Running attribute.
            Assert.That( Service.Status == RunningStatus.Disabled );

            Assert.That( PluginProxy == null );

            if( startPlugin )
            {
                PluginHost.Execute( ReadOnlyListEmpty<IPluginInfo>.Empty, ReadOnlyListEmpty<IPluginInfo>.Empty, new[] { PluginPluginId } );
                Assert.That( PluginProxy.Status == RunningStatus.Started );
                Assert.That( Service.Status == RunningStatus.Started );
            }
        }