-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from lucassklp/improve-request-options
feature: Improvements and bumps
- Loading branch information
Showing
24 changed files
with
293 additions
and
83 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
.idea | ||
.vs | ||
.vscode | ||
.DS_Store |
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,116 @@ | ||
using Models; | ||
using Models.Consumers; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reactive.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Rx.Http.Tests | ||
{ | ||
public class ConsumersTests | ||
{ | ||
private readonly Injector injector; | ||
public ConsumersTests() | ||
{ | ||
injector = new Injector(); | ||
} | ||
|
||
[Fact] | ||
public async Task CheckIfRequestIsWorking() | ||
{ | ||
var tmdbConsumer = injector.Get<TheMovieDatabaseConsumer>(); | ||
var response = await tmdbConsumer.ListMovies(); | ||
|
||
Assert.NotNull(response); | ||
} | ||
|
||
[Fact] | ||
public async Task CheckSameRequestTwice() | ||
{ | ||
var tmdbConsumer = injector.Get<TheMovieDatabaseConsumer>(); | ||
var response1 = await tmdbConsumer.ListMovies(); | ||
var response2 = await tmdbConsumer.ListMovies(); | ||
|
||
Assert.NotNull(response1); | ||
Assert.NotNull(response2); | ||
} | ||
|
||
[Fact] | ||
public async Task TestPostWithBody() | ||
{ | ||
var postmanConsumer = injector.Get<PostmanConsumer>(); | ||
|
||
var todo = new Todo | ||
{ | ||
Id = 12, | ||
Title = "Testing with special characters: àáç~ã*+ü?<>!ºªª", | ||
IsCompleted = true, | ||
UserId = 20 | ||
}; | ||
var response = await postmanConsumer.Post(todo); | ||
|
||
Assert.True(response.Data.Equals(todo)); | ||
} | ||
|
||
[Fact] | ||
public async Task TestQueryStrings() | ||
{ | ||
var postmanConsumer = injector.Get<PostmanConsumer>(); | ||
|
||
var queryStrings = new Dictionary<string, object> | ||
{ | ||
{ "Foo", "Bar" }, | ||
{ "User", "John Doe" }, | ||
{ "Characters", "*&�%6dbajs&@#chv73*(#Y" }, | ||
{ "Boolean", true }, | ||
{ "Int", 1 }, | ||
{ "Float", 1.8129f }, | ||
{ "Double", 1.8129d }, | ||
}; | ||
|
||
var headers = await postmanConsumer.GetWithQueryString(queryStrings); | ||
|
||
Assert.Equal(headers.Args, new Dictionary<string, string> | ||
{ | ||
{ "Foo", "Bar" }, | ||
{ "User", "John Doe" }, | ||
{ "Characters", "*&�%6dbajs&@#chv73*(#Y" }, | ||
{ "Boolean", "true" }, | ||
{ "Int", "1" }, | ||
{ "Float", "1.8129" }, | ||
{ "Double", "1.8129" }, | ||
}); | ||
} | ||
|
||
[Fact] | ||
public async Task TestHeaders() | ||
{ | ||
var postmanConsumer = injector.Get<PostmanConsumer>(); | ||
|
||
var headers = new Dictionary<string, object> | ||
{ | ||
{ "Foo", "Bar" }, | ||
{ "User", "John Doe" }, | ||
{ "Boolean", true }, | ||
{ "Int", 1 }, | ||
{ "Float", 1.8129f }, | ||
{ "Double", 1.8129d }, | ||
}; | ||
|
||
var expected = new Dictionary<string, string> | ||
{ | ||
{ "foo", "Bar" }, | ||
{ "user", "John Doe" }, | ||
{ "boolean", "true" }, | ||
{ "int", "1" }, | ||
{ "float", "1.8129" }, | ||
{ "double", "1.8129" }, | ||
}; | ||
|
||
var response = await postmanConsumer.GetWithHeaders(headers); | ||
var valid = expected.All(pair => response.Headers.ContainsKey(pair.Key) && response.Headers[pair.Key] == pair.Value); | ||
Assert.True(valid); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
using Rx.Http; | ||
using Xunit; | ||
|
||
namespace Tests | ||
namespace Rx.Http.Tests | ||
{ | ||
public class InjectionTests | ||
{ | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
using Rx.Http; | ||
using Xunit; | ||
|
||
namespace Tests | ||
namespace Rx.Http.Tests | ||
{ | ||
public class NavigatorTests | ||
{ | ||
|
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
using Xunit; | ||
using System.IO; | ||
|
||
namespace Tests | ||
namespace Rx.Http.Tests | ||
{ | ||
public class RequestTests | ||
{ | ||
|
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,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Models\Models.csproj" /> | ||
<ProjectReference Include="..\Rx.Http\Rx.Http.csproj" /> | ||
</ItemGroup> | ||
</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
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
Oops, something went wrong.