Skip to content

Commit

Permalink
Add support for export/import of AgileTestPlatformSpecs #8
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefourie committed Mar 25, 2015
1 parent 063bf68 commit 35fb061
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 10 deletions.
25 changes: 25 additions & 0 deletions Manager/TFSBuildManager.Views/ExportedAgileTestPlatformSpec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//-----------------------------------------------------------------------
// <copyright file="ExportedAgileTestPlatformSpec.cs">(c) https://github.com/tfsbuildextensions/BuildManager. This source is subject to the Microsoft Permissive License. See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. All other rights reserved.</copyright>
//-----------------------------------------------------------------------
namespace TfsBuildManager.Views
{
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;

public class ExportedAgileTestPlatformSpec
{
public bool FailBuildOnFailure { get; set; }

public string RunName { get; set; }

public string AssemblyFileSpec { get; set; }

public ExecutionPlatformType ExecutionPlatform { get; set; }

public string RunSettingsFileName { get; set; }

public RunSettingsType TypeRunSettings { get; set; }

public string TestCaseFilter { get; set; }
}
}
2 changes: 2 additions & 0 deletions Manager/TFSBuildManager.Views/ExportedBuildDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public ExportedBuildDefinition()

public string BuildController { get; set; }

public List<ExportedAgileTestPlatformSpec> AgileTestSpecs { get; set; }

public StringList ProjectsToBuild { get; set; }

public PlatformConfigurationList ConfigurationsToBuild { get; set; }
Expand Down
22 changes: 21 additions & 1 deletion Manager/TFSBuildManager.Views/ImportBuildDefinitions.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void ButtonImport_OnClick(object sender, RoutedEventArgs e)

foreach (var param in exdef.ProcessParameters)
{
if (param.Key != "AgentSettings" && param.Key != "BuildSettings")
if (param.Key != "AgentSettings" && param.Key != "BuildSettings" && param.Key != "TestSpecs")
{
Newtonsoft.Json.Linq.JArray arrayItem = param.Value as Newtonsoft.Json.Linq.JArray;
if (arrayItem == null)
Expand Down Expand Up @@ -183,6 +183,26 @@ private void ButtonImport_OnClick(object sender, RoutedEventArgs e)
process.Add("AgentSettings", exdef.GitAgentSettings);
}

if (exdef.AgileTestSpecs != null)
{
TestSpecList tsl = new TestSpecList();
foreach (var aitem in exdef.AgileTestSpecs)
{
AgileTestPlatformSpec agileSpec = new AgileTestPlatformSpec();
agileSpec.AssemblyFileSpec = aitem.AssemblyFileSpec;
agileSpec.ExecutionPlatform = aitem.ExecutionPlatform;
agileSpec.FailBuildOnFailure = aitem.FailBuildOnFailure;
agileSpec.RunName = aitem.RunName;
agileSpec.TestCaseFilter = aitem.TestCaseFilter;
agileSpec.RunSettingsForTestRun = new RunSettings();
agileSpec.RunSettingsForTestRun.ServerRunSettingsFile = aitem.RunSettingsFileName;
agileSpec.RunSettingsForTestRun.TypeRunSettings = aitem.TypeRunSettings;
tsl.Add(agileSpec);
}

process.Add("TestSpecs", tsl);
}

if (exdef.BuildReasons != null)
{
foreach (var key in exdef.BuildReasons.Keys)
Expand Down
1 change: 1 addition & 0 deletions Manager/TFSBuildManager.Views/TFSBuildManager.Views.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<Compile Include="BuildImport.cs" />
<Compile Include="ExportedBuildDefinition.cs" />
<Compile Include="ExportedIBuildDefinitionSourceProvider.cs" />
<Compile Include="ExportedAgileTestPlatformSpec.cs" />
<Compile Include="ExportedIWorkspaceMapping.cs" />
<Compile Include="ExportedISchedule.cs" />
<Compile Include="ExportedIRetentionPolicy.cs" />
Expand Down
43 changes: 34 additions & 9 deletions Manager/TFSBuildManager.Views/ViewModels/BuildManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public BuildManagerViewModel(Window owner, ITfsClientRepository repository, IMai
public ICommand DeleteCommand { get; private set; }

public ICommand DisableCommand { get; private set; }

public ICommand PauseCommand { get; private set; }

public ICommand EnableCommand { get; private set; }
Expand Down Expand Up @@ -145,7 +145,7 @@ public BuildManagerViewModel(Window owner, ITfsClientRepository repository, IMai
public ICommand ViewBuildLogsCommand { get; private set; }

public ICommand ShowQueuedDetailsCommand { get; private set; }

public ICommand ResumeBuildCommand { get; private set; }

public ICommand StopBuildCommand { get; private set; }
Expand All @@ -163,7 +163,7 @@ public BuildManagerViewModel(Window owner, ITfsClientRepository repository, IMai
public ICommand SetBelowNormalPriorityCommand { get; private set; }

public ICommand SetLowPriorityCommand { get; private set; }

public ICommand RetainIndefinitelyCommand { get; private set; }

public ICommand SetBuildQualityCommand { get; private set; }
Expand All @@ -187,7 +187,7 @@ public BuildManagerViewModel(Window owner, ITfsClientRepository repository, IMai
public ICommand SetRetentionPoliciesCommand { get; private set; }

public ICommand ChangeProcessParameterCommand { get; private set; }

public ICommand QueueBuildsCommand { get; private set; }

public ICommand QueueHighBuildsCommand { get; private set; }
Expand All @@ -205,7 +205,7 @@ public BuildManagerViewModel(Window owner, ITfsClientRepository repository, IMai
public ICommand RemapWorkspacesCommand { get; private set; }

public ICommand RefreshCurrentView { get; private set; }

public ICommand ImportBuildDefinition { get; private set; }

public ObservableCollection<BuildDefinitionViewModel> BuildDefinitions { get; private set; }
Expand Down Expand Up @@ -441,6 +441,31 @@ public static void ExportDefinition(BuildDefinitionViewModel b, string filePath)
}
}

if (processParameters.ContainsKey("TestSpecs"))
{
var testSpecs = processParameters["TestSpecs"] as TestSpecList;
if (testSpecs != null)
{
buildToExport.AgileTestSpecs = new List<ExportedAgileTestPlatformSpec>();
foreach (var spec in testSpecs)
{
var agilespec = spec as AgileTestPlatformSpec;
if (agilespec != null)
{
ExportedAgileTestPlatformSpec expAgileSpec = new ExportedAgileTestPlatformSpec();
expAgileSpec.AssemblyFileSpec = agilespec.AssemblyFileSpec;
expAgileSpec.ExecutionPlatform = agilespec.ExecutionPlatform;
expAgileSpec.FailBuildOnFailure = agilespec.FailBuildOnFailure;
expAgileSpec.RunName = agilespec.RunName;
expAgileSpec.TestCaseFilter = agilespec.TestCaseFilter;
expAgileSpec.RunSettingsFileName = agilespec.RunSettingsForTestRun.ServerRunSettingsFile;
expAgileSpec.TypeRunSettings = agilespec.RunSettingsForTestRun.TypeRunSettings;
buildToExport.AgileTestSpecs.Add(expAgileSpec);
}
}
}
}

buildToExport.ProcessParameters = WorkflowHelpers.DeserializeProcessParameters(b.BuildDefinition.ProcessParameters);
foreach (KeyValuePair<string, object> item in processParameters)
{
Expand Down Expand Up @@ -799,7 +824,7 @@ public void SetQueuedBuildPriority(QueuePriority priority)
try
{
var items = this.view.SelectedActiveBuilds.ToList();

if (!items.Any())
{
return;
Expand Down Expand Up @@ -1189,7 +1214,7 @@ private void OnRefreshCurrentView()
{
this.OnRefresh(new EventArgs());
}

private void OnImportBuildDefinition()
{
if (this.view.SelectedTeamProject == "All")
Expand Down Expand Up @@ -1369,7 +1394,7 @@ private void OnCloneBuildToProject()
private void OnRemapWorkspaces()
{
try
{
{
if (this.selectedBuildView == BuildView.BuildDefinitions)
{
var buildDefinition = this.view.SelectedItems.First().BuildDefinition;
Expand Down Expand Up @@ -1631,7 +1656,7 @@ private void OnChangeTrigger()
this.view.DisplayError(ex);
}
}

private void OnChangeOutputLocationAsConfiguredCommand()
{
var items = this.view.SelectedItems;
Expand Down

0 comments on commit 35fb061

Please sign in to comment.