Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void SimulateTestLoad()
[TestCase("ForceStopButton", false)]
[TestCase("SaveResultsCommand", false)]
[TestCase("TransformResultsCommand", false)]
[TestCase("TestRunSettingsCommand", true)]
public void CheckCommandEnabled(string propName, bool enabled)
{
ViewElement(propName).Received().Enabled = enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void SimulateTestUnload()
[TestCase("RunParametersButton", false)]
[TestCase("StopRunButton", false)]
[TestCase("ForceStopButton", false)]
[TestCase("TestRunSettingsCommand", false)]
public void CheckCommandEnabled(string propName, bool enabled)
{
ViewElement(propName).Received().Enabled = enabled;
Expand Down
6 changes: 5 additions & 1 deletion src/GuiRunner/TestCentric.Gui/Dialogs/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ public static void Display(TestCentricPresenter presenter, ITestModel model)
TreeBasedSettingsDialog.Display(presenter, model,
new GuiSettingsPage("General"),
new TreeSettingsPage("Tree Display", presenter.ImageSetManager),
new AdvancedLoaderSettingsPage("Assembly Load Settings"),
new AssemblyReloadSettingsPage("Automatic Reload"),
new ProjectEditorSettingsPage("Project Editor"));
}

public static void DisplayTestRunSettings(TestCentricPresenter presenter, ITestModel model)
{
TreeBasedSettingsDialog.Display(presenter, model, new AdvancedLoaderSettingsPage("Assembly Load Settings"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ void OnRunFinished(ResultNode result)
SettingsDialog.Display(this, _model);
};

_view.TestRunSettingsCommand.Execute += () =>
{
SettingsDialog.DisplayTestRunSettings(this, _model);
};

_view.TestCentricHelpCommand.Execute += () =>
{
System.Diagnostics.Process.Start("https://test-centric.org/testcentric-gui");
Expand Down Expand Up @@ -776,6 +781,7 @@ private void UpdateViewCommands(bool testLoading = false)
_view.RecentFilesMenu.Enabled = !testRunning && !testLoading;
_view.ExitCommand.Enabled = !testLoading;
_view.SaveResultsCommand.Enabled = _view.TransformResultsCommand.Enabled = !testRunning && !testLoading && hasResults;
_view.TestRunSettingsCommand.Enabled = testLoaded && !testRunning;
}

private void UpdateRunSelectedTestsTooltip()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace TestCentric.Gui.SettingsPages
{
using NUnit.Engine;

public class AdvancedLoaderSettingsPage : SettingsPage
{
private System.Windows.Forms.Label label3;
Expand Down Expand Up @@ -239,41 +241,44 @@ private void InitializeComponent()
}
#endregion

private PackageSettings PackageSettings => Model.TestCentricProject.Settings;

public override void LoadSettings()
{
int agents = Settings.Engine.Agents;

// Update UI elements based on current settings in TestCentricProject
int agents = PackageSettings.GetValueOrDefault(SettingDefinitions.MaxAgents);
numberOfAgentsCheckBox.Checked = agents > 0;
numberOfAgentsUpDown.Value = agents;

disableShadowCopyCheckBox.Checked = !Settings.Engine.ShadowCopyFiles;
disableShadowCopyCheckBox.Checked = !PackageSettings.GetValueOrDefault(SettingDefinitions.ShadowCopyFiles); ;

string principalPolicy = PackageSettings.GetValueOrDefault(SettingDefinitions.PrincipalPolicy);
if (string.IsNullOrEmpty(principalPolicy))
principalPolicy = nameof(PrincipalPolicy.UnauthenticatedPrincipal);

principalPolicyCheckBox.Checked = principalPolicyListBox.Enabled =
Settings.Engine.SetPrincipalPolicy;
principalPolicyListBox.SelectedItem = Settings.Engine.PrincipalPolicy;
principalPolicy != nameof(PrincipalPolicy.UnauthenticatedPrincipal);
principalPolicyListBox.SelectedItem = principalPolicy;
}

public override void ApplySettings()
{
// Check if current values in UI elements differ from those in TestCentricProject
// If values differ, add them to SettingsChanges list, so they can be applied later
int numAgents = numberOfAgentsCheckBox.Checked
? (int)numberOfAgentsUpDown.Value : 0;
if (numAgents != Settings.Engine.Agents)
if (numAgents != PackageSettings.GetValueOrDefault(SettingDefinitions.MaxAgents))
TopLevelPackageSettingChanges.Add(SettingDefinitions.MaxAgents.WithValue(numAgents));
Settings.Engine.Agents = numAgents;

bool shadowCopyFiles = !disableShadowCopyCheckBox.Checked;
if (shadowCopyFiles != Settings.Engine.ShadowCopyFiles)
if (shadowCopyFiles != PackageSettings.GetValueOrDefault(SettingDefinitions.ShadowCopyFiles))
SubPackageSettingChanges.Add(SettingDefinitions.ShadowCopyFiles.WithValue(shadowCopyFiles));
Settings.Engine.ShadowCopyFiles = shadowCopyFiles;

string principalPolicy = principalPolicyCheckBox.Checked
? (string)principalPolicyListBox.SelectedItem
: nameof(PrincipalPolicy.UnauthenticatedPrincipal);
if (principalPolicy != Settings.Engine.PrincipalPolicy)
if (principalPolicy != PackageSettings.GetValueOrDefault(SettingDefinitions.PrincipalPolicy))
SubPackageSettingChanges.Add(SettingDefinitions.PrincipalPolicy.WithValue(principalPolicy));
Settings.Engine.PrincipalPolicy = principalPolicy;

Settings.Engine.SetPrincipalPolicy = principalPolicyCheckBox.Checked;
}

private void numberOfAgentsCheckBox_CheckedChanged(object sender, EventArgs e)
Expand All @@ -284,6 +289,8 @@ private void numberOfAgentsCheckBox_CheckedChanged(object sender, EventArgs e)
private void principalPolicyCheckBox_CheckedChanged(object sender, EventArgs e)
{
principalPolicyListBox.Enabled = principalPolicyCheckBox.Checked;
if (!principalPolicyCheckBox.Checked)
principalPolicyListBox.SelectedItem = nameof(PrincipalPolicy.UnauthenticatedPrincipal);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/GuiRunner/TestCentric.Gui/Views/IMainView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public interface IMainView
ICommand OpenWorkDirectoryCommand { get; }
ICommand ExtensionsCommand { get; }
ICommand SettingsCommand { get; }
ICommand TestRunSettingsCommand { get; }

// Help Menu Items
ICommand TestCentricHelpCommand { get; }
Expand Down
13 changes: 12 additions & 1 deletion src/GuiRunner/TestCentric.Gui/Views/TestCentricMainView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class TestCentricMainView : TestCentricFormBase, IMainView

private System.Windows.Forms.ToolStripMenuItem toolsMenu;
private System.Windows.Forms.ToolStripMenuItem settingsMenuItem;
private System.Windows.Forms.ToolStripMenuItem testRunSettingsMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveResultsMenuItem;
private System.Windows.Forms.ToolStripMenuItem transformResultsMenuItem;

Expand Down Expand Up @@ -142,6 +143,7 @@ public TestCentricMainView() : base("TestCentric")
CloseProjectCommand = new CommandMenuElement(closeMenuItem);
AddTestFilesCommand = new CommandMenuElement(addTestFileMenuItem);
ReloadTestsCommand = new CommandMenuElement(reloadTestsMenuItem);
TestRunSettingsCommand = new CommandMenuElement(testRunSettingsMenuItem);
SelectAgentMenu = new PopupMenuElement(selectAgentMenu);
RunAsX86 = new CheckedMenuElement(runAsX86MenuItem);
RecentFilesMenu = new PopupMenuElement(recentFilesMenu);
Expand Down Expand Up @@ -287,6 +289,7 @@ private void InitializeComponent()
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.extensionsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.testRunSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpItem = new System.Windows.Forms.ToolStripMenuItem();
this.testCentricHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.nunitHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem();
Expand Down Expand Up @@ -580,8 +583,9 @@ private void InitializeComponent()
this.addTestFileMenuItem,
this.toolStripSeparator1,
this.reloadTestsMenuItem,
this.selectAgentMenu,
this.toolStripSeparator2,
this.testRunSettingsMenuItem,
this.selectAgentMenu,
this.runAsX86MenuItem,
this.toolStripSeparator3,
this.recentFilesMenu,
Expand Down Expand Up @@ -866,6 +870,12 @@ private void InitializeComponent()
this.settingsMenuItem.Size = new System.Drawing.Size(194, 22);
this.settingsMenuItem.Text = "&Settings...";
//
// testRunSettingsMenuItem
//
this.testRunSettingsMenuItem.Name = "testRunSettingsMenuItem";
this.testRunSettingsMenuItem.Size = new System.Drawing.Size(194, 22);
this.testRunSettingsMenuItem.Text = "&Test Run Settings...";
//
// helpItem
//
this.helpItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
Expand Down Expand Up @@ -1202,6 +1212,7 @@ public int SplitterPosition
public ICommand OpenWorkDirectoryCommand { get; }
public ICommand ExtensionsCommand { get; }
public ICommand SettingsCommand { get; }
public ICommand TestRunSettingsCommand { get; }

// Help Menu Items
public ICommand TestCentricHelpCommand { get; }
Expand Down
8 changes: 0 additions & 8 deletions src/GuiRunner/TestModel.Tests/Settings/EngineSettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,11 @@ public void Setup()
public static TestCaseData[] DefaultValueTestCases = new TestCaseData[]
{
new TestCaseData(nameof(EngineSettings.RerunOnChange), "false"),
new TestCaseData(nameof(EngineSettings.ShadowCopyFiles), "true"),
new TestCaseData(nameof(EngineSettings.Agents), "0"),
new TestCaseData(nameof(EngineSettings.SetPrincipalPolicy), "false"),
new TestCaseData(nameof(EngineSettings.PrincipalPolicy), "UnauthenticatedPrincipal")
};

public static TestCaseData[] SetValueTestCases = new TestCaseData[]
{
new TestCaseData(nameof(EngineSettings.RerunOnChange), false),
new TestCaseData(nameof(EngineSettings.ShadowCopyFiles), true),
new TestCaseData(nameof(EngineSettings.Agents), 0),
new TestCaseData(nameof(EngineSettings.SetPrincipalPolicy), false),
new TestCaseData(nameof(EngineSettings.PrincipalPolicy), "UnauthenticatedPrincipal")
};
}
}
40 changes: 0 additions & 40 deletions src/GuiRunner/TestModel/Settings/EngineSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ namespace TestCentric.Gui.Model.Settings

public interface IEngineSettings
{
bool ShadowCopyFiles { get; set; }

int Agents { get; set; }

bool RerunOnChange { get; set; }

bool SetPrincipalPolicy { get; set; }

string PrincipalPolicy { get; set; }
}


Expand All @@ -28,44 +20,12 @@ public interface IEngineSettings
/// </summary>
public class EngineSettings : ApplicationSettingsBase, IEngineSettings
{
[UserScopedSetting]
[DefaultSettingValue("true")]
public bool ShadowCopyFiles
{
get { return (bool)this[nameof(ShadowCopyFiles)]; }
set { this[nameof(ShadowCopyFiles)] = value; }
}

[UserScopedSetting]
[DefaultSettingValue("0")]
public int Agents
{
get { return (int)this[nameof(Agents)]; }
set { this[nameof(Agents)] = value; }
}

[UserScopedSetting]
[DefaultSettingValue("false")]
public bool RerunOnChange
{
get { return (bool)this[nameof(RerunOnChange)]; }
set { this[nameof(RerunOnChange)] = value; }
}

[UserScopedSetting]
[DefaultSettingValue("false")]
public bool SetPrincipalPolicy
{
get { return (bool)this[nameof(SetPrincipalPolicy)]; }
set { this[nameof(SetPrincipalPolicy)] = value; }
}

[UserScopedSetting]
[DefaultSettingValue(nameof(System.Security.Principal.PrincipalPolicy.UnauthenticatedPrincipal))]
public string PrincipalPolicy
{
get { return (string)this[nameof(PrincipalPolicy)]; }
set { this[nameof(PrincipalPolicy)] = value; }
}
}
}
17 changes: 9 additions & 8 deletions src/GuiRunner/TestModel/TestCentricProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace TestCentric.Gui.Model
{
using System.Linq;

public class TestCentricProject : NUnit.Engine.TestPackage
{
private ITestModel _model;
Expand Down Expand Up @@ -40,15 +42,10 @@ public TestCentricProject(ITestModel model, IList<string> filenames)
_model = model;
TestFiles = new List<string>(filenames);

var engineSettings = _model.Settings.Engine;
var options = model.Options;

if (engineSettings.Agents > 0)
SetTopLevelSetting(SettingDefinitions.MaxAgents.WithValue(engineSettings.Agents));
if (engineSettings.SetPrincipalPolicy)
SetSubPackageSetting(SettingDefinitions.PrincipalPolicy.WithValue(engineSettings.PrincipalPolicy));
SetSubPackageSetting(SettingDefinitions.ShadowCopyFiles.WithValue(engineSettings.ShadowCopyFiles));
// Turn on shadow copy in new TestCentric project by default
SetSubPackageSetting(SettingDefinitions.ShadowCopyFiles.WithValue(true));

var options = model.Options;
if (options != null) // Happens when we test
{
SetSubPackageSetting(SettingDefinitions.InternalTraceLevel.WithValue(options.InternalTraceLevel ?? "Off"));
Expand Down Expand Up @@ -96,7 +93,11 @@ public void Load(string path)
Settings.Set(packageSetting);

foreach (var subPackage in newPackage.SubPackages)
{
AddSubPackage(subPackage.FullName);
foreach (var setting in subPackage.Settings)
SubPackages.Last().Settings.Set(setting);
}

LoadTests();
}
Expand Down