-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from penguinho/master
Initial commit
- Loading branch information
Showing
31 changed files
with
2,958 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<solution> | ||
<add key="disableSourceControlIntegration" value="true" /> | ||
</solution> | ||
</configuration> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> | ||
|
||
<!-- Enable the restore command to run before builds --> | ||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages> | ||
|
||
<!-- Property that enables building a package from a project --> | ||
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage> | ||
|
||
<!-- Determines if package restore consent is required to restore packages --> | ||
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent> | ||
|
||
<!-- Download NuGet.exe if it does not already exist --> | ||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition=" '$(PackageSources)' == '' "> | ||
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used --> | ||
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list --> | ||
<!-- | ||
<PackageSource Include="https://www.nuget.org/api/v2/" /> | ||
<PackageSource Include="https://my-nuget-source/nuget/" /> | ||
--> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'"> | ||
<!-- Windows specific commands --> | ||
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> | ||
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'"> | ||
<!-- We need to launch nuget.exe with the mono command if we're not on windows --> | ||
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath> | ||
<PackagesConfig>packages.config</PackagesConfig> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- NuGet command --> | ||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath> | ||
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources> | ||
|
||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand> | ||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand> | ||
|
||
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> | ||
|
||
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch> | ||
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch> | ||
|
||
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir> | ||
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir> | ||
|
||
<!-- Commands --> | ||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand> | ||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand> | ||
|
||
<!-- We need to ensure packages are restored prior to assembly resolve --> | ||
<BuildDependsOn Condition="$(RestorePackages) == 'true'"> | ||
RestorePackages; | ||
$(BuildDependsOn); | ||
</BuildDependsOn> | ||
|
||
<!-- Make the build depend on restore packages --> | ||
<BuildDependsOn Condition="$(BuildPackage) == 'true'"> | ||
$(BuildDependsOn); | ||
BuildPackage; | ||
</BuildDependsOn> | ||
</PropertyGroup> | ||
|
||
<Target Name="CheckPrerequisites"> | ||
<!-- Raise an error if we're unable to locate nuget.exe --> | ||
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> | ||
<!-- | ||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once. | ||
This effectively acts as a lock that makes sure that the download operation will only happen once and all | ||
parallel builds will have to wait for it to complete. | ||
--> | ||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" /> | ||
</Target> | ||
|
||
<Target Name="_DownloadNuGet"> | ||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" /> | ||
</Target> | ||
|
||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> | ||
<Exec Command="$(RestoreCommand)" | ||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" /> | ||
|
||
<Exec Command="$(RestoreCommand)" | ||
LogStandardErrorAsError="true" | ||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> | ||
</Target> | ||
|
||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites"> | ||
<Exec Command="$(BuildCommand)" | ||
Condition=" '$(OS)' != 'Windows_NT' " /> | ||
|
||
<Exec Command="$(BuildCommand)" | ||
LogStandardErrorAsError="true" | ||
Condition=" '$(OS)' == 'Windows_NT' " /> | ||
</Target> | ||
|
||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> | ||
<ParameterGroup> | ||
<OutputFilename ParameterType="System.String" Required="true" /> | ||
</ParameterGroup> | ||
<Task> | ||
<Reference Include="System.Core" /> | ||
<Using Namespace="System" /> | ||
<Using Namespace="System.IO" /> | ||
<Using Namespace="System.Net" /> | ||
<Using Namespace="Microsoft.Build.Framework" /> | ||
<Using Namespace="Microsoft.Build.Utilities" /> | ||
<Code Type="Fragment" Language="cs"> | ||
<![CDATA[ | ||
try { | ||
OutputFilename = Path.GetFullPath(OutputFilename); | ||
Log.LogMessage("Downloading latest version of NuGet.exe..."); | ||
WebClient webClient = new WebClient(); | ||
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename); | ||
return true; | ||
} | ||
catch (Exception ex) { | ||
Log.LogErrorFromException(ex); | ||
return false; | ||
} | ||
]]> | ||
</Code> | ||
</Task> | ||
</UsingTask> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2012 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{C7307807-F4CD-44C6-AB5D-BD5F38D575DF}" | ||
ProjectSection(SolutionItems) = preProject | ||
.nuget\NuGet.Config = .nuget\NuGet.Config | ||
.nuget\NuGet.exe = .nuget\NuGet.exe | ||
.nuget\NuGet.targets = .nuget\NuGet.targets | ||
EndProjectSection | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestRail", "TestRail\TestRail.csproj", "{68C04A3F-DA7C-4588-8AA8-11A01C13630B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{68C04A3F-DA7C-4588-8AA8-11A01C13630B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{68C04A3F-DA7C-4588-8AA8-11A01C13630B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{68C04A3F-DA7C-4588-8AA8-11A01C13630B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{68C04A3F-DA7C-4588-8AA8-11A01C13630B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
|
||
namespace TestRail | ||
{ | ||
/// <summary>represents the result of a command </summary> | ||
public class CommandResult : CommandResult<string> | ||
{ | ||
/// <summary>constructor</summary> | ||
/// <param name="wasSuccessful">true if the command was successful</param> | ||
/// <param name="result">result of the command</param> | ||
/// <param name="e">exception thrown by the command</param> | ||
public CommandResult(bool wasSuccessful, string result, Exception e = null) : base(wasSuccessful, result, e) { } | ||
} | ||
|
||
/// <summary>represents the result of a command</summary> | ||
/// <typeparam name="T">type of the result</typeparam> | ||
public class CommandResult<T> | ||
{ | ||
/// <summary>true if the command was successful</summary> | ||
public bool WasSuccessful { get; set; } | ||
/// <summary>result of the command</summary> | ||
public T Value { get; set; } | ||
/// <summary>exception thrown by the command</summary> | ||
public Exception Exception { get; set; } | ||
|
||
/// <summary>parameterless constructor</summary> | ||
public CommandResult() | ||
{ | ||
WasSuccessful = false; | ||
Value = default(T); | ||
Exception = null; | ||
} | ||
|
||
/// <summary>constructor</summary> | ||
/// <param name="wasSuccessful">true if the command was successful</param> | ||
/// <param name="result">result of the command</param> | ||
/// <param name="e">exception thrown by the command</param> | ||
public CommandResult(bool wasSuccessful, T result, Exception e=null) | ||
{ | ||
WasSuccessful = wasSuccessful; | ||
Value = result; | ||
Exception = e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace TestRail | ||
{ | ||
/// <summary>extension methods for the datetime class</summary> | ||
public static class DateTimeExtensions | ||
{ | ||
/// <summary>converts the date to a unix timestamp</summary> | ||
/// <returns>a unix time stamp representing the birthday</returns> | ||
public static double ToUnixTimestamp(this DateTime dt) | ||
{ | ||
return dt.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; | ||
} | ||
|
||
/// <summary>generates a datetime from a unix timestamp</summary> | ||
/// <param name="timestamp">a unix timestamp</param> | ||
/// <returns>datetime corresponding to the supplied unix timestamp</returns> | ||
public static DateTime FromUnixTimeStamp(double timestamp) | ||
{ | ||
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(timestamp).ToLocalTime(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace TestRail | ||
{ | ||
/// <summary> | ||
/// Helper class for Json Objects | ||
/// </summary> | ||
internal static class JsonUtility | ||
{ | ||
/// <summary>Merge two Json Objects</summary> | ||
/// <param name="obj1">object 1 to merge</param> | ||
/// <param name="obj2">object 2 to merge</param> | ||
/// <returns>a non null Json object (NOTE: may be empty)</returns> | ||
internal static JObject Merge(JObject obj1, JObject obj2) | ||
{ | ||
if (null == obj1) | ||
{ | ||
obj1 = new JObject(); | ||
} | ||
|
||
if (null != obj2) | ||
{ | ||
JToken token = obj2.First; | ||
while (null != token) | ||
{ | ||
obj1.Add(token); | ||
token = token.Next; | ||
} | ||
} | ||
return obj1; | ||
} | ||
|
||
/// <summary>Converts a JArray into a List of type T</summary> | ||
/// <param name="jarray">JArray to parse</param> | ||
/// <returns>returns a list of objects corresponding to the json, empty list if nothing exists</returns> | ||
internal static List<T> ConvertJArrayToList<T>(JArray jarray, Func<JObject, T> parse) | ||
{ | ||
List<T> list = new List<T>(); | ||
if (null != jarray && null != parse) | ||
{ | ||
foreach (JObject json in jarray) | ||
{ | ||
list.Add(parse(json)); | ||
} | ||
} | ||
return list; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("TestRail")] | ||
[assembly: AssemblyDescription("TestRail Client Library")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Zoosk")] | ||
[assembly: AssemblyProduct("TestRail Client Library for .NET")] | ||
[assembly: AssemblyCopyright("Copyright © 2013")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(true)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("b91a1174-5709-412a-9e95-ccaad637454c")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.