Skip to content

Commit

Permalink
config file usage added
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Jan 15, 2014
1 parent 2166fa8 commit 7b17297
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 53 deletions.
7 changes: 7 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="url" value="" />
<add key="login" value="" />
<add key="password" value="" />
<add key="project" value="" />
<add key="testplan" value="" />
</appSettings>
</configuration>
53 changes: 17 additions & 36 deletions CLAPOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Threading.Tasks;
using CLAP;
using CLAP.Validation;
Expand All @@ -13,7 +14,14 @@ class CLAPOptions : ITfsCliOptions
private static CLAPOptions _instance;
private static IDictionary<string, string> _opts = new Dictionary<string, string>();
private static string _verb;

private static Configuration configManager = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
private KeyValueConfigurationCollection _appconf;

private CLAPOptions()
{
_appconf = configManager.AppSettings.Settings;
//_appconf["YourKey"].Value = "YourNewKey";
}

public static CLAPOptions getOptions()
{
Expand All @@ -39,22 +47,7 @@ public string ProvidedVerb()
{
return _verb;
}
/*
[Global(Description = "TFS collection url, e.g. 'https://my.visualstudio.com/DefaultCollection'")]
static void url(string value){
_opts["url"] = value;
}

[Global(Description = "TFS project name to get tests from")]
static void project(string value){
_opts["project"] = value;
}
[Global(Description = "TFS testplan name to get tests from")]
static void testplan(string value)
{
_opts["testplan"] = value;
}
*/
[Global(Aliases = "lgn", Description = "TFS user login")]
static void login(string value)
{
Expand Down Expand Up @@ -87,34 +80,22 @@ static void help()
}

[Verb(Aliases = "get",
Description = "Exports TFS tests from provided project and testplan.\nExample: 'g -url=\"https://ekhatko.visualstudio.com/DefaultCollection\" -p=\"cmd\" -t=\"\"bestplan\"\" -lgn=\"[email protected]\" -pwd=\"Qwerty14\"'"
Description = "Exports TFS tests from provided project and testplan. Please fill App.config file beforehand\nUsage: tfs_cli get"
)]
static void get_tests(
[RequiredAttribute, DescriptionAttribute("TFS collection url, e.g. 'https://my.visualstudio.com/DefaultCollection")]
string url,
[RequiredAttribute, DescriptionAttribute("TFS project name to get tests from")]
string project,
[RequiredAttribute, DescriptionAttribute("TFS testplan name to get tests from")]
string testplan,
[DefaultValue("tests.xml"), DescriptionAttribute("Filename for tests export")]
string output
)
{
_verb = "get_tests";
_opts["url"] = url;
_opts["project"] = project;
_opts["testplan"] = testplan;
_opts["url"] = _instance._appconf["url"].Value;
_opts["project"] = _instance._appconf["project"].Value; ;
_opts["testplan"] = _instance._appconf["testplan"].Value; ;
_opts["output"] = output;
}

[Verb(Aliases = "upd", Description = "Updates TFS test with provided attributes.\nExample: ''")]
[Verb(Aliases = "upd", Description = "Updates TFS test with provided attributes. Please fill App.config file beforehand\nUsage: ''")]
static void update_test(
[RequiredAttribute, DescriptionAttribute("TFS collection url, e.g. 'https://my.visualstudio.com/DefaultCollection")]
string url,
[RequiredAttribute, DescriptionAttribute("TFS project name to get tests from")]
string project,
[RequiredAttribute, DescriptionAttribute("TFS testplan name to get tests from")]
string testplan,
[AliasesAttribute("rconf"), DescriptionAttribute("Run configuration"), DefaultValue("tfs_cli")]
string run_config,
[AliasesAttribute("rd"), RequiredAttribute, DescriptionAttribute("Run duration")]
Expand Down Expand Up @@ -144,9 +125,9 @@ string test_attachment
)
{
_verb = "update_test";
_opts["url"] = url;
_opts["project"] = project;
_opts["testplan"] = testplan;
_opts["url"] = _instance._appconf["url"].Value;
_opts["project"] = _instance._appconf["project"].Value; ;
_opts["testplan"] = _instance._appconf["testplan"].Value; ;
_opts["run_config"] = run_config;
_opts["duration"] = duration;
_opts["run_title"] = run_title;
Expand Down
2 changes: 2 additions & 0 deletions XmlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public void Append(ITestCase test) {
new XElement("is_automated", test.IsAutomated),
new XElement("area", test.Area)
);
IEnumerator iterator = test.Actions.GetEnumerator();
foreach(ITestAction action in test.Actions){
iterator.MoveNext();
XElement a = new XElement("action");
a.Add(
new XAttribute("id", action.Id),
Expand Down
28 changes: 11 additions & 17 deletions tfs_cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,22 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CLAP">
<HintPath>..\packages\CLAP.4.4\lib\net35\CLAP.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Work\Tfs-Api\Assembly\Microsoft.TeamFoundation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Work\Tfs-Api\Assembly\12.0\Microsoft.TeamFoundation.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.TestManagement.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Work\Tfs-Api\Assembly\12.0\Microsoft.TeamFoundation.TestManagement.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Work\Tfs-Api\Assembly\12.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll</HintPath>
<HintPath>assembly\CLAP.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.TestManagement.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.TeamFoundation.WorkItemTracking.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="FirstTfsApi.cs" />
Expand Down Expand Up @@ -116,6 +107,9 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit 7b17297

Please sign in to comment.