Skip to content

Commit

Permalink
Merge pull request #17 from 2gis/feature/status-command
Browse files Browse the repository at this point in the history
Add status command implementation
  • Loading branch information
NickAb committed May 5, 2015
2 parents 5250c69 + c60b14f commit 7eff848
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Winium.Desktop.Driver/CommandExecutors/StatusExecutor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Winium.Desktop.Driver.CommandExecutors
{
#region using

using System.Collections.Generic;

using Winium.Desktop.Driver.CommandHelpers;
using Winium.StoreApps.Common;

#endregion

internal class StatusExecutor : CommandExecutorBase
{
#region Methods

protected override string DoImpl()
{
var response = new Dictionary<string, object> { { "build", new BuildInfo() }, { "os", new OSInfo() } };
return this.JsonResponse(ResponseStatus.Success, response);
}

#endregion
}
}
32 changes: 32 additions & 0 deletions src/Winium.Desktop.Driver/CommandHelpers/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Winium.Desktop.Driver.CommandHelpers
{
#region using

using System.Reflection;

using Newtonsoft.Json;

#endregion

public class BuildInfo
{
#region Static Fields

private static string version;

#endregion

#region Public Properties

[JsonProperty("version")]
public string Version
{
get
{
return version ?? (version = Assembly.GetExecutingAssembly().GetName().Version.ToString());
}
}

#endregion
}
}
53 changes: 53 additions & 0 deletions src/Winium.Desktop.Driver/CommandHelpers/OSInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace Winium.Desktop.Driver.CommandHelpers
{
#region using

using System;

using Newtonsoft.Json;

#endregion

// ReSharper disable once InconsistentNaming
public class OSInfo
{
#region Static Fields

private static string architecture;

private static string version;

#endregion

#region Public Properties

[JsonProperty("arch")]
public string Architecture
{
get
{
return architecture ?? (architecture = Environment.Is64BitOperatingSystem ? "x64" : "x86");
}
}

[JsonProperty("name")]
public string Name
{
get
{
return "windows";
}
}

[JsonProperty("version")]
public string Version
{
get
{
return version ?? (version = Environment.OSVersion.VersionString);
}
}

#endregion
}
}
3 changes: 3 additions & 0 deletions src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<ItemGroup>
<Compile Include="Automator\Automator.cs" />
<Compile Include="Automator\Capabilities.cs" />
<Compile Include="CommandExecutors\StatusExecutor.cs" />
<Compile Include="CommandExecutors\SubmitElementExecutor.cs" />
<Compile Include="CommandExecutors\ExecuteScriptExecutor.cs" />
<Compile Include="CommandExecutors\ElementEqualsExecutor.cs" />
Expand Down Expand Up @@ -103,6 +104,8 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Requester.cs" />
<Compile Include="CommandHelpers\OSInfo.cs" />
<Compile Include="CommandHelpers\BuildInfo.cs" />
<Compile Include="UriDispatchTables.cs" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 7eff848

Please sign in to comment.