-
Notifications
You must be signed in to change notification settings - Fork 39
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
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
tests/Unleash.Tests/Communication/UnleashApiClient_Project_Tests.cs
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 System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
using Unleash.Communication; | ||
using Unleash.Serialization; | ||
using Unleash.Tests.Mock; | ||
|
||
namespace Unleash.Tests.Communication | ||
{ | ||
public class UnleashApiClient_Project_Tests | ||
{ | ||
[Test] | ||
public async Task FetchToggles_ForProject() | ||
{ | ||
var apiUri = new Uri("http://unleash.herokuapp.com/api/"); | ||
var project = "testproject"; | ||
|
||
var jsonSerializer = new DynamicNewtonsoftJsonSerializer(); | ||
jsonSerializer.TryLoad(); | ||
|
||
var requestHeaders = new UnleashApiClientRequestHeaders | ||
{ | ||
AppName = "api-test-client", | ||
InstanceTag = "instance1", | ||
CustomHttpHeaders = null, | ||
CustomHttpHeaderProvider = null | ||
}; | ||
|
||
var messageHandler = new MockHttpMessageHandler(); | ||
var httpClient = new HttpClient(messageHandler) | ||
{ | ||
BaseAddress = apiUri, | ||
Timeout = TimeSpan.FromSeconds(5) | ||
}; | ||
|
||
var client = new UnleashApiClient(httpClient, jsonSerializer, requestHeaders, project); | ||
var toggles = await client.FetchToggles("", CancellationToken.None); | ||
toggles.Should().NotBeNull(); | ||
messageHandler.SentMessages.Count.Should().Be(1); | ||
messageHandler.SentMessages.First().RequestUri.Query.Should().Be("?project=" + 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