Skip to content

Commit

Permalink
Fix #51 Added test for config saving plugin enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Green committed Mar 7, 2014
1 parent d535892 commit a026898
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
50 changes: 50 additions & 0 deletions src/Procon.Core.Test/Plugins/TestPluginConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Procon.Core.Connections;
using Procon.Core.Connections.Plugins;
using Procon.Core.Shared;
using Procon.Core.Shared.Models;

namespace Procon.Core.Test.Plugins {
[TestFixture]
public class TestPluginConfig {
/// <summary>
/// Tests that an enabled plugin will have the enabled command saved to the config
/// </summary>
[Test]
public void TestEnabledPluginSavedToConfig() {
Guid connectionGuid = Guid.NewGuid();
Guid onePluginGuid = Guid.NewGuid();
Guid twoPluginGuid = Guid.NewGuid();

ICorePluginController plugins = new CorePluginController() {
Connection = new ConnectionController() {
ConnectionModel = new ConnectionModel() {
ConnectionGuid = connectionGuid
}
},
LoadedPlugins = new List<PluginModel>() {
new PluginModel() {
Name = "One",
IsEnabled = false,
PluginGuid = onePluginGuid
},
new PluginModel() {
Name = "Two",
IsEnabled = true,
PluginGuid = twoPluginGuid
}
}
};

IConfig config = new Config().Create<CorePluginController>();

plugins.WriteConfig(config);

Assert.AreEqual(config.Root.First.Value<String>("Name"), "PluginsEnable");
Assert.AreEqual(config.Root.First["ScopeModel"].Value<String>("ConnectionGuid"), connectionGuid.ToString());
Assert.AreEqual(config.Root.First["ScopeModel"].Value<String>("PluginGuid"), twoPluginGuid.ToString());
}
}
}
2 changes: 2 additions & 0 deletions src/Procon.Core.Test/Procon.Core.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Xdt.1.0.0\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -91,6 +92,7 @@
<Compile Include="Packages\TestPackageCacheBuilders.cs" />
<Compile Include="Packages\TestPackagesController.cs" />
<Compile Include="Packages\TestRepositoryCache.cs" />
<Compile Include="Plugins\TestPluginConfig.cs" />
<Compile Include="Plugins\TestPlugins.cs" />
<Compile Include="Plugins\TestPluginsDisabled.cs" />
<Compile Include="Plugins\TestPluginsEnabled.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Procon.Core.Connections.Plugins {
/// a plugin back to Procon.
/// </summary>
public class CorePluginController : AsynchronousCoreController, ISharedReferenceAccess, ICorePluginController {
public List<PluginModel> LoadedPlugins { get; protected set; }
public List<PluginModel> LoadedPlugins { get; set; }

/// <summary>
/// The appdomain all of the plugins are loaded into.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public interface ICorePluginController : ICoreController {
/// <summary>
/// List of plugins loaded in the app domain.
/// </summary>
List<PluginModel> LoadedPlugins { get; }
List<PluginModel> LoadedPlugins { get; set; }
}
}

0 comments on commit a026898

Please sign in to comment.