Skip to content

Commit

Permalink
JSON response by default; Session duration could be 0; Fixes tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
virtyaluk committed Aug 27, 2016
1 parent d1716b4 commit 895f2e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ModernDev.InTouch.Shared/InTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public async Task<Response<T>> Request<T>(string methodName, Dictionary<string,

CacheReqData(methodName, normalizedParams, isOpenMethod, path);

var json = await Post($"method/{methodName}.json", normalizedParams);
var json = await Post($"method/{methodName}", normalizedParams);

return await Task.Run(() => ParseJsonReponse<T>(json, path));
}
Expand Down
2 changes: 1 addition & 1 deletion ModernDev.InTouch.Tests/Ex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class Ex
{
private static MockHttpMessageHandler WhenAndRespond(this MockHttpMessageHandler @this, string url, string json)
{
@this.When($"/method/{url}.json").Respond("application/json", json);
@this.When($"/method/{url}").Respond("application/json", json);

return @this;
}
Expand Down
15 changes: 8 additions & 7 deletions ModernDev.InTouch.Tests/GeneralClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void SettingSessionData()

Throws<ArgumentNullException>(() => _it1.SetSessionData("", 0));
Throws<ArgumentException>(() => _it1.SetSessionData("access_token", 0));
Throws<ArgumentException>(() => _it1.SetSessionData("access_token", 1, 0));
Throws<ArgumentException>(() => _it1.SetSessionData("access_token", 1, -1));
Throws<ArgumentNullException>(() => _it1.SetSessionData(null));
DoesNotThrow(() => _it1.SetSessionData("access_token", 1));
IsNotNull(_it1.Session, "_it1.Session != null");
Expand Down Expand Up @@ -113,7 +113,7 @@ public void Post()

DoesNotThrowAsync(async () =>
{
respJson = await _inTouch.Post("/method/test.json", _emptyDict);
respJson = await _inTouch.Post("/method/test", _emptyDict);
});

IsNotEmpty(respJson, "respJson");
Expand Down Expand Up @@ -144,11 +144,12 @@ public void Request()
ThrowsAsync<NullReferenceException>(async () => await _inTouch.Request<bool>("test"));
DoesNotThrowAsync(async () => await _inTouch.Request<bool>("test", isOpenMethod: true));

_inTouch.Session = new APISession("access_token", 12345, 0);

ThrowsAsync<InTouchException>(async () => await _inTouch.Request<bool>("test"));

_inTouch.SetApplicationSettings(12345, "super_secret");
/*
* Next won't work since session duration could be equal to zero
* _inTouch.Session = new APISession("access_token", 12345, 0);
* ThrowsAsync<InTouchException>(async () => await _inTouch.Request<bool>("test"));
* _inTouch.SetApplicationSettings(12345, "super_secret");
*/
}

[Test]
Expand Down

0 comments on commit 895f2e6

Please sign in to comment.