Skip to content

Commit

Permalink
Merge pull request #28 from feedhenry/coverage
Browse files Browse the repository at this point in the history
Coverage
  • Loading branch information
edewit committed Nov 13, 2015
2 parents e80d8e1 + 6432c57 commit 172e3de
Show file tree
Hide file tree
Showing 103 changed files with 3,382 additions and 1,357 deletions.
207 changes: 150 additions & 57 deletions FHSDK.sln

Large diffs are not rendered by default.

Binary file modified FHSDK.v12.suo
Binary file not shown.
8 changes: 7 additions & 1 deletion FHSDK/API/FHAuthSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
using FHSDK.Services.Data;

namespace FHSDK.API
{
{
/// <summary>
/// FHAuthSession is resposible to manage OAuth tokens.
/// </summary>
public sealed class FHAuthSession
{
private const string SessionTokenKey = "sessionToken";
Expand All @@ -19,6 +22,9 @@ private FHAuthSession()
{
}

/// <summary>
/// Get unique instance of FHAuthSession singleton.
/// </summary>
public static FHAuthSession GetInstance
{
get { return Instance; }
Expand Down
148 changes: 79 additions & 69 deletions FHSDK/Config/CloudProps.cs
Original file line number Diff line number Diff line change
@@ -1,70 +1,80 @@
using FHSDK.Config;
using Newtonsoft.Json.Linq;

namespace FHSDK
{
/// <summary>
/// Class represents the cloud app instance (MBAAS service) the app should be communication with.
/// </summary>
public class CloudProps
{
private readonly JObject _cloudPropsJson;
private string _env;
private string _hostUrl;

/// <summary>
/// Constructor
/// </summary>
/// <param name="props">The json format of the cloud host info</param>
public CloudProps(JObject props)
{
_cloudPropsJson = props;
}

/// <summary>
/// Return the cloud host info as URL
/// </summary>
/// <returns>the cloud host url</returns>
public string GetCloudHost()
{
if (null != _hostUrl) return _hostUrl;
if (null != _cloudPropsJson["url"])
{
_hostUrl = (string) _cloudPropsJson["url"];
}
else
{
var hosts = (JObject) _cloudPropsJson["hosts"];
if (null != hosts["url"])
{
_hostUrl = (string) hosts["url"];
}
else
{
var appMode = FHConfig.GetInstance().GetMode();
if ("dev" == appMode)
{
_hostUrl = (string) hosts["debugCloudUrl"];
}
else
{
_hostUrl = (string) hosts["releaseCloudUrl"];
}
}
}
_hostUrl = _hostUrl.EndsWith("/") ? _hostUrl.Substring(0, _hostUrl.Length - 1) : _hostUrl;
return _hostUrl;
}

public string GetEnv()
{
if (null != _env) return _env;
var hosts = (JObject) _cloudPropsJson["hosts"];
if (null != hosts["environment"])
{
_env = (string) hosts["environment"];
}
return _env;
}
}
using FHSDK.Config;
using Newtonsoft.Json.Linq;

namespace FHSDK
{
/// <summary>
/// Class represents the cloud app instance (MBAAS service) the app should be communication with.
/// </summary>
public class CloudProps
{
private readonly JObject _cloudPropsJson;
private string _env;
private string _hostUrl;
private readonly FHConfig _config;

/// <summary>
/// Constructor
/// </summary>
/// <param name="props">The json format of the cloud host info</param>
public CloudProps(JObject props)
{
_cloudPropsJson = props;
_config = FHConfig.GetInstance();
}
/// <summary>
/// Constructor used for unit testing and injecting mock.
/// </summary>
/// <param name="props"></param>
public CloudProps(JObject props, FHConfig config)
{
_cloudPropsJson = props;
_config = config;
}
/// <summary>
/// Return the cloud host info as URL
/// </summary>
/// <returns>the cloud host url</returns>
public string GetCloudHost()
{
if (null != _hostUrl) return _hostUrl;
if (null != _cloudPropsJson["url"])
{
_hostUrl = (string) _cloudPropsJson["url"];
}
else
{
var hosts = (JObject) _cloudPropsJson["hosts"];
if (null != hosts["url"])
{
_hostUrl = (string) hosts["url"];
}
else
{
var appMode = _config.GetMode();
if ("dev" == appMode)
{
_hostUrl = (string) hosts["debugCloudUrl"];
}
else
{
_hostUrl = (string) hosts["releaseCloudUrl"];
}
}
}
_hostUrl = _hostUrl.EndsWith("/") ? _hostUrl.Substring(0, _hostUrl.Length - 1) : _hostUrl;
return _hostUrl;
}

public string GetEnv()
{
if (null != _env) return _env;
var hosts = (JObject) _cloudPropsJson["hosts"];
if (null != hosts["environment"])
{
_env = (string) hosts["environment"];
}
return _env;
}
}
}
Loading

0 comments on commit 172e3de

Please sign in to comment.