-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
159 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,49 @@ | ||
using Bunq.Sdk.Context; | ||
using Xunit; | ||
|
||
namespace Bunq.Sdk.Tests.Context | ||
{ | ||
/// <summary> | ||
/// Tests: | ||
/// ApiContext | ||
/// </summary> | ||
public class ApiContextTest : BunqSdkTestBase, IClassFixture<ApiContextTest> | ||
{ | ||
/// <summary> | ||
/// Path to a temporary context file. | ||
/// </summary> | ||
private const string CONTEXT_FILENAME_TEST = "context-save-restore-test.conf"; | ||
|
||
private static ApiContext apiContext; | ||
|
||
public ApiContextTest() | ||
{ | ||
if (apiContext == null) apiContext = GetApiContext(); | ||
} | ||
|
||
/// <summary> | ||
/// Tests serialization and de-serialization of the API context. | ||
/// </summary> | ||
[Fact] | ||
public void TestApiContextSerializeDeserialize() | ||
{ | ||
var apiContextJson = apiContext.ToJson(); | ||
var apiContextDeSerialised = ApiContext.FromJson(apiContextJson); | ||
|
||
Assert.Equal(apiContextJson, apiContextDeSerialised.ToJson()); | ||
} | ||
|
||
/// <summary> | ||
/// Tests saving and restoring of the API context. | ||
/// </summary> | ||
[Fact] | ||
public void TestApiContextSaveRestore() | ||
{ | ||
var apiContextJson = apiContext.ToJson(); | ||
apiContext.Save(CONTEXT_FILENAME_TEST); | ||
var apiContextRestored = ApiContext.Restore(CONTEXT_FILENAME_TEST); | ||
|
||
Assert.Equal(apiContextJson, apiContextRestored.ToJson()); | ||
} | ||
} | ||
} |
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
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
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
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,32 @@ | ||
using System; | ||
using System.Net; | ||
|
||
namespace Bunq.Sdk.Http | ||
{ | ||
public class BunqProxy : IWebProxy | ||
{ | ||
public BunqProxy(string proxyUri) | ||
: this(new Uri(proxyUri)) | ||
{ | ||
} | ||
|
||
public BunqProxy(Uri proxyUri) | ||
{ | ||
ProxyUri = proxyUri; | ||
} | ||
|
||
public Uri ProxyUri { get; set; } | ||
|
||
public ICredentials Credentials { get; set; } | ||
|
||
public Uri GetProxy(Uri destination) | ||
{ | ||
return ProxyUri; | ||
} | ||
|
||
public bool IsBypassed(Uri host) | ||
{ | ||
return false; /* Proxy all requests */ | ||
} | ||
} | ||
} |
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
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
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