Пример #1
0
        public void ApplicationExitEvents()
        {
            {
                TestContextHost host = new TestContextHost("TestContexts");

                IContext c = host.CreateContext();

                bool before = false, after = false;
                c.ApplicationExiting += ( o, e ) => { Assert.That( e.HostShouldExit ); before = true; };
                c.ApplicationExited += ( o, e ) => { Assert.That( e.HostShouldExit ); after = true; };

                Assert.That( c.RaiseExitApplication( true ) );
                Assert.That( before && after );
            }
            {
                TestContextHost host = new TestContextHost("TestContexts");

                IContext c = host.CreateContext();

                bool before = false, after = false;
                c.ApplicationExiting += ( o, e ) => { e.Cancel = true; before = true; };
                c.ApplicationExited += ( o, e ) => after = true;

                Assert.That( c.RaiseExitApplication( false ), Is.False );
                Assert.That( before && after == false );
            }
        }
Пример #2
0
        public void CheckSystemConfigurationInstances()
        {
            // Creates system configuration with one user profile.
            {
                var host = new TestContextHost("CheckSystemConfigurationInstances");
                File.Delete(host.SystemConfigAddress.LocalPath);
                File.Delete(host.DefaultUserConfigAddress.LocalPath);
                var ctx = host.CreateContext();

                Assert.That(ctx.ConfigManager.UserConfiguration != null, "Creation of a default User profile.");
                Assert.That(ctx.ConfigManager.SystemConfiguration.CurrentUserProfile.DisplayName == Environment.UserName, "Default became automatically active.");

                var p2 = ctx.ConfigManager.SystemConfiguration.UserProfiles.FindOrCreate(GetTestFileUri("UserProfile"));
                p2.DisplayName = "2nd profile...";

                host.UserConfig["Toto"] = 3;

                Assert.That(ctx.ConfigManager.SystemConfiguration.CurrentUserProfile.DisplayName == Environment.UserName, "The last active is still the default one.");

                host.SaveUserConfig();
                host.SaveSystemConfig();

                TestBase.DumpFileToConsole(host.SystemConfigAddress.LocalPath);
                TestBase.DumpFileToConsole(host.DefaultUserConfigAddress.LocalPath);
            }
            // Reloads it.
            {
                var host = new TestContextHost("CheckSystemConfigurationInstances");
                var ctx  = host.CreateContext();

                Assert.That(ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo(2), "Accessing SystemConfiguration triggers the load.");
                Assert.That(host.UserConfig["Toto"], Is.EqualTo(3), "Accessing UserConfiguration triggers the load.");
            }
        }
Пример #3
0
        public void CheckSystemConfigurationInstances()
        {
            // Creates system configuration with one user profile.
            {
                var host = new TestContextHost( "CheckSystemConfigurationInstances" );
                File.Delete( host.SystemConfigAddress.LocalPath );
                File.Delete( host.DefaultUserConfigAddress.LocalPath );
                var ctx = host.CreateContext();
                
                Assert.That( ctx.ConfigManager.UserConfiguration != null, "Creation of a default User profile." );
                Assert.That( ctx.ConfigManager.SystemConfiguration.CurrentUserProfile.DisplayName == Environment.UserName, "Default became automatically active." );

                var p2 = ctx.ConfigManager.SystemConfiguration.UserProfiles.FindOrCreate( GetTestFileUri( "UserProfile" ) );
                p2.DisplayName = "2nd profile...";
                
                host.UserConfig["Toto"] = 3;

                Assert.That( ctx.ConfigManager.SystemConfiguration.CurrentUserProfile.DisplayName == Environment.UserName, "The last active is still the default one." );

                host.SaveUserConfig();
                host.SaveSystemConfig();

                TestBase.DumpFileToConsole( host.SystemConfigAddress.LocalPath );
                TestBase.DumpFileToConsole( host.DefaultUserConfigAddress.LocalPath );
            }
            // Reloads it.
            {
                var host = new TestContextHost( "CheckSystemConfigurationInstances" );
                var ctx = host.CreateContext();

                Assert.That( ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo( 2 ), "Accessing SystemConfiguration triggers the load." );
                Assert.That( host.UserConfig["Toto"], Is.EqualTo( 3 ), "Accessing UserConfiguration triggers the load." );
            }
        }
Пример #4
0
        public void ApplicationExitEvents()
        {
            {
                TestContextHost host = new TestContextHost("TestContexts");

                IContext c = host.CreateContext();

                bool before = false, after = false;
                c.ApplicationExiting += (o, e) => { Assert.That(e.HostShouldExit); before = true; };
                c.ApplicationExited  += (o, e) => { Assert.That(e.HostShouldExit); after = true; };

                Assert.That(c.RaiseExitApplication(true));
                Assert.That(before && after);
            }
            {
                TestContextHost host = new TestContextHost("TestContexts");

                IContext c = host.CreateContext();

                bool before = false, after = false;
                c.ApplicationExiting += (o, e) => { e.Cancel = true; before = true; };
                c.ApplicationExited  += (o, e) => after = true;

                Assert.That(c.RaiseExitApplication(false), Is.False);
                Assert.That(before && after == false);
            }
        }
        public void TestExceptions()
        {
            TestContextHost host = new TestContextHost("TestContexts");
            
            IContext c = host.CreateContext();

            c.LogCenter.EventCreated += LogEventListener;
            c.ApplicationExited += OnExitOK;

            c.RaiseExitApplication( false );
            Assert.That( _onExitOKCalled && !_onExitKOCalled, "Just to test that events work." );

            _onExitOKCalled = false;
            c.ApplicationExited += OnExitKO;
            c.RaiseExitApplication( false );
            Assert.That( _onExitOKCalled && _onExitKOCalled && _exceptionLogged, "The exception has been caught." );

            // Removes the handler and adds it back so that it appears after the buggy one.
            c.ApplicationExited -= OnExitOK;
            c.ApplicationExited += OnExitOK;
            _onExitOKCalled = _onExitKOCalled = _exceptionLogged = false;
            c.RaiseExitApplication( false );
            Assert.That( _onExitOKCalled && _onExitKOCalled && _exceptionLogged, "The exception has been caught, the remaining subscribers have been called." );
        
        }
Пример #6
0
        public void ApplicationExitDisableRunner()
        {
            Guid simplePluginId = new Guid("{EEAEC976-2AFC-4A68-BFAD-68E169677D52}");

            TestContextHost host = new TestContextHost("TestContexts");

            IContext c = host.CreateContext();

            TestBase.CopyPluginToTestDir("SimplePlugin.dll");
            c.PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);
            var pluginId = c.PluginRunner.Discoverer.FindPlugin(simplePluginId);

            Assert.That(pluginId, Is.Not.Null);

            Assert.That(c.PluginRunner.PluginHost.IsPluginRunning(pluginId), Is.False);
            Assert.That(c.PluginRunner.PluginHost.IsPluginRunning(pluginId.PluginId), Is.False);

            var req = new RequirementLayer("Start SimplePlugin");

            req.PluginRequirements.AddOrSet(simplePluginId, RunningRequirement.MustExistAndRun);
            c.PluginRunner.Add(req);
            c.PluginRunner.Apply();

            Assert.That(c.PluginRunner.PluginHost.IsPluginRunning(pluginId), Is.True, "SimplePlugin is running.");
            Assert.That(c.PluginRunner.PluginHost.IsPluginRunning(pluginId.PluginId), Is.True, "SimplePlugin is running.");

            int eventPhasis = 0;

            c.PluginRunner.PluginHost.StatusChanged += (o, e) =>
            {
                Assert.That(eventPhasis >= 0 && eventPhasis < 3);
                Assert.That(e.PluginProxy.PluginKey.PluginId, Is.EqualTo(simplePluginId));
                if (eventPhasis == 0)
                {
                    Assert.That(e.Previous, Is.EqualTo(RunningStatus.Started));
                    Assert.That(e.PluginProxy.Status, Is.EqualTo(RunningStatus.Stopping));
                    eventPhasis = 1;
                }
                else if (eventPhasis == 1)
                {
                    Assert.That(e.Previous, Is.EqualTo(RunningStatus.Stopping));
                    Assert.That(e.PluginProxy.Status, Is.EqualTo(RunningStatus.Stopped));
                    eventPhasis = 2;
                }
                else if (eventPhasis == 2)
                {
                    Assert.That(e.Previous, Is.EqualTo(RunningStatus.Stopped));
                    Assert.That(e.PluginProxy.Status, Is.EqualTo(RunningStatus.Disabled));
                    eventPhasis = 3;
                }
            };

            Assert.That(c.RaiseExitApplication(true));

            Assert.That(c.PluginRunner.PluginHost.IsPluginRunning(pluginId), Is.False, "SimplePlugin is no more running.");
            Assert.That(c.PluginRunner.PluginHost.IsPluginRunning(pluginId.PluginId), Is.False, "SimplePlugin is no more running.");
        }
Пример #7
0
        public void ApplicationExitDisableRunner()
        {
            Guid simplePluginId = new Guid( "{EEAEC976-2AFC-4A68-BFAD-68E169677D52}" );

            TestContextHost host = new TestContextHost("TestContexts");

            IContext c = host.CreateContext();

            TestBase.CopyPluginToTestDir( "SimplePlugin.dll" );
            c.PluginRunner.Discoverer.Discover( TestBase.TestFolderDir, true );
            var pluginId = c.PluginRunner.Discoverer.FindPlugin( simplePluginId );
            Assert.That( pluginId, Is.Not.Null );

            Assert.That( c.PluginRunner.PluginHost.IsPluginRunning( pluginId ), Is.False );
            Assert.That( c.PluginRunner.PluginHost.IsPluginRunning( pluginId.PluginId ), Is.False );

            var req = new RequirementLayer( "Start SimplePlugin" );
            req.PluginRequirements.AddOrSet( simplePluginId, RunningRequirement.MustExistAndRun );
            c.PluginRunner.Add( req );
            c.PluginRunner.Apply();

            Assert.That( c.PluginRunner.PluginHost.IsPluginRunning( pluginId ), Is.True, "SimplePlugin is running." );
            Assert.That( c.PluginRunner.PluginHost.IsPluginRunning( pluginId.PluginId ), Is.True, "SimplePlugin is running." );

            int eventPhasis = 0;
            c.PluginRunner.PluginHost.StatusChanged += ( o, e ) =>
            {
                Assert.That( eventPhasis >= 0 && eventPhasis < 3 );
                Assert.That( e.PluginProxy.PluginKey.PluginId, Is.EqualTo( simplePluginId ) );
                if( eventPhasis == 0 )
                {
                    Assert.That( e.Previous, Is.EqualTo( RunningStatus.Started ) );
                    Assert.That( e.PluginProxy.Status, Is.EqualTo( RunningStatus.Stopping ) );
                    eventPhasis = 1;
                }
                else if( eventPhasis == 1 )
                {
                    Assert.That( e.Previous, Is.EqualTo( RunningStatus.Stopping ) );
                    Assert.That( e.PluginProxy.Status, Is.EqualTo( RunningStatus.Stopped ) );
                    eventPhasis = 2;
                }
                else if( eventPhasis == 2 )
                {
                    Assert.That( e.Previous, Is.EqualTo( RunningStatus.Stopped ) );
                    Assert.That( e.PluginProxy.Status, Is.EqualTo( RunningStatus.Disabled ) );
                    eventPhasis = 3;
                }
            };

            Assert.That( c.RaiseExitApplication( true ) );

            Assert.That( c.PluginRunner.PluginHost.IsPluginRunning( pluginId ), Is.False, "SimplePlugin is no more running." );
            Assert.That( c.PluginRunner.PluginHost.IsPluginRunning( pluginId.PluginId ), Is.False, "SimplePlugin is no more running." );
        }
Пример #8
0
        public void ReloadPreviousContext()
        {
            INamedVersionedUniqueId pluginId = new SimpleNamedVersionedUniqueId(Guid.NewGuid(), Util.EmptyVersion, "JustForTest");

            // Creates typical user configuration.
            {
                var host = new TestContextHost("ReloadPreviousContext");
                File.Delete(host.SystemConfigAddress.LocalPath);
                File.Delete(host.DefaultUserConfigAddress.LocalPath);

                var ctx = host.CreateContext();

                Assert.That(ctx.ConfigManager.SystemConfiguration != null);
                Assert.That(ctx.ConfigManager.UserConfiguration != null, "Accessing it, creates it.");
                Assert.That(ctx.ConfigManager.SystemConfiguration.UserProfiles.Current, Is.Not.Null, "It becomes the current one.");

                Assert.That(!ctx.ConfigManager.Extended.Container.Contains(pluginId), "The plugin is not known yet.");
                ctx.ConfigManager.Extended.Container[ctx, pluginId, "testKey"] = "testValue";
                Assert.That(ctx.ConfigManager.Extended.Container.Contains(pluginId), "Setting a value ensures that the plugin is registered.");


                host.SaveContext(GetTestFileUri("Context"));
                host.SaveUserConfig();
                host.SaveSystemConfig();

                TestBase.DumpFileToConsole(GetTestFileUri("Context").LocalPath);
            }

            // Loads existing configuration.
            {
                var host = new TestContextHost("ReloadPreviousContext");
                var ctx  = host.CreateContext();

                ctx.ConfigManager.Extended.Container.Ensure(pluginId);
                host.LoadContext();

                Assert.That(ctx.ConfigManager.Extended.Container[ctx, pluginId, "testKey"], Is.EqualTo("testValue"));
            }
        }
Пример #9
0
        public void ReloadPreviousContext()
        {
            INamedVersionedUniqueId pluginId = new SimpleNamedVersionedUniqueId( Guid.NewGuid(), Util.EmptyVersion, "JustForTest" );

            // Creates typical user configuration.
            {
                var host = new TestContextHost( "ReloadPreviousContext" );
                File.Delete( host.SystemConfigAddress.LocalPath );
                File.Delete( host.DefaultUserConfigAddress.LocalPath );
                
                var ctx = host.CreateContext();

                Assert.That( ctx.ConfigManager.SystemConfiguration != null );
                Assert.That( ctx.ConfigManager.UserConfiguration != null, "Accessing it, creates it." );
                Assert.That( ctx.ConfigManager.SystemConfiguration.UserProfiles.Current, Is.Not.Null, "It becomes the current one." );

                Assert.That( !ctx.ConfigManager.Extended.Container.Contains( pluginId ), "The plugin is not known yet." );
                ctx.ConfigManager.Extended.Container[ctx, pluginId, "testKey"] = "testValue";
                Assert.That( ctx.ConfigManager.Extended.Container.Contains( pluginId ), "Setting a value ensures that the plugin is registered." );


                host.SaveContext( GetTestFileUri( "Context" ) );
                host.SaveUserConfig();
                host.SaveSystemConfig();

                TestBase.DumpFileToConsole( GetTestFileUri( "Context" ).LocalPath );
            }

            // Loads existing configuration.
            {
                var host = new TestContextHost( "ReloadPreviousContext" );
                var ctx = host.CreateContext();
                
                ctx.ConfigManager.Extended.Container.Ensure( pluginId );
                host.LoadContext();

                Assert.That( ctx.ConfigManager.Extended.Container[ctx, pluginId, "testKey"], Is.EqualTo( "testValue" ) );
            }
        }
        public void TestExceptions()
        {
            TestContextHost host = new TestContextHost("TestContexts");

            IContext c = host.CreateContext();

            c.LogCenter.EventCreated += LogEventListener;
            c.ApplicationExited      += OnExitOK;

            c.RaiseExitApplication(false);
            Assert.That(_onExitOKCalled && !_onExitKOCalled, "Just to test that events work.");

            _onExitOKCalled      = false;
            c.ApplicationExited += OnExitKO;
            c.RaiseExitApplication(false);
            Assert.That(_onExitOKCalled && _onExitKOCalled && _exceptionLogged, "The exception has been caught.");

            // Removes the handler and adds it back so that it appears after the buggy one.
            c.ApplicationExited -= OnExitOK;
            c.ApplicationExited += OnExitOK;
            _onExitOKCalled      = _onExitKOCalled = _exceptionLogged = false;
            c.RaiseExitApplication(false);
            Assert.That(_onExitOKCalled && _onExitKOCalled && _exceptionLogged, "The exception has been caught, the remaining subscribers have been called.");
        }
Пример #11
0
        public void ChangeEmptyToFilled()
        {
            Guid id1 = Guid.NewGuid();
            Guid id2 = Guid.NewGuid();
            Guid id3 = Guid.NewGuid();

            // Creates empty configuration files.
            {
                var host = new TestContextHost("ChangeEmptyToFilled");
                var ctx  = host.CreateContext();
                File.Delete(host.SystemConfigAddress.LocalPath);
                File.Delete(host.DefaultUserConfigAddress.LocalPath);

                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id1, ConfigPluginStatus.AutomaticStart);
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id2, ConfigPluginStatus.Disabled);
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id3, ConfigPluginStatus.Manual);

                Assert.That(ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus(id1, ConfigPluginStatus.ConfigurationMask), Is.EqualTo(ConfigPluginStatus.AutomaticStart));

                host.SaveUserConfig();
                host.SaveSystemConfig();
            }
            // Creates second user configuration file
            {
                var host = new TestContextHost("ChangeEmptyToFilled");
                var ctx  = host.CreateContext();

                Assert.That(ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus(id1, ConfigPluginStatus.ConfigurationMask), Is.EqualTo(ConfigPluginStatus.AutomaticStart),
                            "Accessing the UserConfiguration triggers the load of last active profile: we find back the good configuration.");

                // Creates a second profile.
                var p2 = ctx.ConfigManager.SystemConfiguration.UserProfiles.FindOrCreate(GetTestFileUri("UsrConf2"));
                Assert.That(ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo(2), "Our System configuration MUST now contains 2 profiles.");
                // Consider it as the last active one: it will be used by SaveUserConfig() without parameter.
                ctx.ConfigManager.SystemConfiguration.CurrentUserProfile = p2;

                // Change the plugin configuration.
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id1, ConfigPluginStatus.Manual);

                host.SaveUserConfig();

                // Change the plugin configuration again and use the SaveUserConfig( u ) that creates and
                // activates a 3rd profile.
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id1, ConfigPluginStatus.Disabled);
                host.SaveUserConfig(GetTestFileUri("UsrConf3"), true);

                Assert.That(ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo(3), "Our System configuration MUST now contains 3 profiles.");
                // - The original, default one, where plugin id1 is AutomaticStart.
                // - The UsrConf2 where plugin id1 is Manual.
                // - The UsrConf3 where plugin id1 is Disabled.
                host.SaveSystemConfig();
            }

            // Reloading...
            {
                var host = new TestContextHost("ChangeEmptyToFilled");
                TestBase.DumpFileToConsole(host.SystemConfigAddress.LocalPath);
                var ctx = host.CreateContext();

                Assert.That(ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo(3), "The 3 profiles are here!");
                Assert.That(ctx.ConfigManager.SystemConfiguration.CurrentUserProfile.Address, Is.EqualTo(GetTestFileUri("UsrConf3")), "The 3rd one is active.");
                Assert.That(ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus(id1, ConfigPluginStatus.ConfigurationMask), Is.EqualTo(ConfigPluginStatus.Disabled), "Where id1 is disabled.");

                // To check that underlying objects instances do not change when we load another profile.
                int userConfigHashCode             = ctx.ConfigManager.UserConfiguration.GetHashCode();
                int pluginStatusCollectionHashCode = ctx.ConfigManager.UserConfiguration.PluginsStatus.GetHashCode();

                IUriHistory p2 = ctx.ConfigManager.SystemConfiguration.UserProfiles.Find(GetTestFileUri("UsrConf2"));
                host.LoadUserConfig(p2.Address);

                Assert.That(ctx.ConfigManager.SystemConfiguration.CurrentUserProfile == p2, "The last active profile has been updated by the Load.");

                Assert.That(ctx.ConfigManager.UserConfiguration.GetHashCode() == userConfigHashCode &&
                            ctx.ConfigManager.UserConfiguration.PluginsStatus.GetHashCode() == pluginStatusCollectionHashCode, "Instances are preserved (their content have changed).");

                Assert.That(ctx.ConfigManager.UserConfiguration.PluginsStatus.Count, Is.EqualTo(3), "We have 3 plugins configured in profile n°2.");
                Assert.That(ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus(id1, ConfigPluginStatus.ConfigurationMask) == ConfigPluginStatus.Manual, "Plugin id1 is Manual in profile n°2.");
                Assert.That(ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus(id2, ConfigPluginStatus.ConfigurationMask) == ConfigPluginStatus.Disabled);
                Assert.That(ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus(id3, ConfigPluginStatus.ConfigurationMask) == ConfigPluginStatus.Manual);
            }
        }
Пример #12
0
        public void ChangeEmptyToFilled()
        {
            Guid id1 = Guid.NewGuid();
            Guid id2 = Guid.NewGuid();
            Guid id3 = Guid.NewGuid();

            // Creates empty configuration files.
            {
                var host = new TestContextHost( "ChangeEmptyToFilled" );
                var ctx = host.CreateContext();
                File.Delete( host.SystemConfigAddress.LocalPath );
                File.Delete( host.DefaultUserConfigAddress.LocalPath );

                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus( id1, ConfigPluginStatus.AutomaticStart );
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus( id2, ConfigPluginStatus.Disabled );
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus( id3, ConfigPluginStatus.Manual );

                Assert.That( ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus( id1, ConfigPluginStatus.ConfigurationMask ), Is.EqualTo( ConfigPluginStatus.AutomaticStart ) );

                host.SaveUserConfig();
                host.SaveSystemConfig();
            }
            // Creates second user configuration file
            {
                var host = new TestContextHost( "ChangeEmptyToFilled" );
                var ctx = host.CreateContext();

                Assert.That( ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus( id1, ConfigPluginStatus.ConfigurationMask ), Is.EqualTo( ConfigPluginStatus.AutomaticStart ),
                    "Accessing the UserConfiguration triggers the load of last active profile: we find back the good configuration." );

                // Creates a second profile.
                var p2 = ctx.ConfigManager.SystemConfiguration.UserProfiles.FindOrCreate( GetTestFileUri( "UsrConf2" ) );
                Assert.That( ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo( 2 ), "Our System configuration MUST now contains 2 profiles." );
                // Consider it as the last active one: it will be used by SaveUserConfig() without parameter.
                ctx.ConfigManager.SystemConfiguration.CurrentUserProfile = p2;
                
                // Change the plugin configuration.
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus( id1, ConfigPluginStatus.Manual );

                host.SaveUserConfig();
                
                // Change the plugin configuration again and use the SaveUserConfig( u ) that creates and
                // activates a 3rd profile.
                ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus( id1, ConfigPluginStatus.Disabled );
                host.SaveUserConfig( GetTestFileUri( "UsrConf3" ), true );

                Assert.That( ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo( 3 ), "Our System configuration MUST now contains 3 profiles." );
                // - The original, default one, where plugin id1 is AutomaticStart.
                // - The UsrConf2 where plugin id1 is Manual.
                // - The UsrConf3 where plugin id1 is Disabled.
                host.SaveSystemConfig();
            }

            // Reloading...
            {
                var host = new TestContextHost( "ChangeEmptyToFilled" );
                TestBase.DumpFileToConsole( host.SystemConfigAddress.LocalPath );
                var ctx = host.CreateContext();

                Assert.That( ctx.ConfigManager.SystemConfiguration.UserProfiles.Count, Is.EqualTo( 3 ), "The 3 profiles are here!" );
                Assert.That( ctx.ConfigManager.SystemConfiguration.CurrentUserProfile.Address, Is.EqualTo( GetTestFileUri( "UsrConf3" ) ), "The 3rd one is active." );
                Assert.That( ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus( id1, ConfigPluginStatus.ConfigurationMask ), Is.EqualTo( ConfigPluginStatus.Disabled ), "Where id1 is disabled." );

                // To check that underlying objects instances do not change when we load another profile.
                int userConfigHashCode = ctx.ConfigManager.UserConfiguration.GetHashCode();
                int pluginStatusCollectionHashCode = ctx.ConfigManager.UserConfiguration.PluginsStatus.GetHashCode();

                IUriHistory p2 = ctx.ConfigManager.SystemConfiguration.UserProfiles.Find( GetTestFileUri( "UsrConf2" ) );
                host.LoadUserConfig( p2.Address );
                
                Assert.That( ctx.ConfigManager.SystemConfiguration.CurrentUserProfile == p2, "The last active profile has been updated by the Load." );

                Assert.That( ctx.ConfigManager.UserConfiguration.GetHashCode() == userConfigHashCode 
                    && ctx.ConfigManager.UserConfiguration.PluginsStatus.GetHashCode() == pluginStatusCollectionHashCode, "Instances are preserved (their content have changed)." );

                Assert.That( ctx.ConfigManager.UserConfiguration.PluginsStatus.Count, Is.EqualTo( 3 ), "We have 3 plugins configured in profile n°2." );
                Assert.That( ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus( id1, ConfigPluginStatus.ConfigurationMask ) == ConfigPluginStatus.Manual, "Plugin id1 is Manual in profile n°2." );
                Assert.That( ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus( id2, ConfigPluginStatus.ConfigurationMask ) == ConfigPluginStatus.Disabled );
                Assert.That( ctx.ConfigManager.UserConfiguration.PluginsStatus.GetStatus( id3, ConfigPluginStatus.ConfigurationMask ) == ConfigPluginStatus.Manual );
            }
        }