-
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 #14 from lucassklp/develop
Version 1.0.0
- Loading branch information
Showing
10 changed files
with
118 additions
and
22 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
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 |
---|---|---|
@@ -1,8 +1,36 @@ | ||
namespace Rx.Http.Tests | ||
using Models.Consumers; | ||
using System.Reactive.Linq; | ||
using Xunit; | ||
|
||
namespace Tests | ||
{ | ||
internal class ConsumersTests | ||
public class ConsumersTests | ||
{ | ||
private Injector injector; | ||
public ConsumersTests() | ||
{ | ||
injector = new Injector(); | ||
} | ||
|
||
[Fact] | ||
public async void CheckIfRequestIsWorking() | ||
{ | ||
var tmdbConsumer = this.injector.Get<TheMovieDatabaseConsumer>(); | ||
var response = await tmdbConsumer.ListMovies(); | ||
|
||
Assert.NotNull(response); | ||
} | ||
|
||
[Fact] | ||
public async void CheckSameRequestTwice() | ||
{ | ||
var tmdbConsumer = this.injector.Get<TheMovieDatabaseConsumer>(); | ||
var response1 = await tmdbConsumer.ListMovies(); | ||
var response2 = await tmdbConsumer.ListMovies(); | ||
|
||
Assert.NotNull(response1); | ||
Assert.NotNull(response2); | ||
} | ||
|
||
} | ||
} |
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,34 @@ | ||
using Models.Consumers; | ||
using Rx.Http; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace Tests | ||
{ | ||
public class InjectionTests | ||
{ | ||
private Injector injector; | ||
public InjectionTests() | ||
{ | ||
injector = new Injector(); | ||
} | ||
|
||
[Fact] | ||
public void CheckIfConsumerIsInjected() | ||
{ | ||
var tmdbConsumer = this.injector.Get<TheMovieDatabaseConsumer>(); | ||
|
||
Assert.NotNull(tmdbConsumer); | ||
} | ||
|
||
[Fact] | ||
public void CheckIfRxHttpClientIsInjected() | ||
{ | ||
var http = this.injector.Get<RxHttpClient>(); | ||
|
||
Assert.NotNull(http); | ||
} | ||
} | ||
} |
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,35 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Models.Consumers; | ||
using Rx.Http; | ||
using System; | ||
|
||
namespace Tests | ||
{ | ||
class Injector | ||
{ | ||
private ServiceProvider serviceProvider; | ||
public Injector() | ||
{ | ||
var serviceCollection = new ServiceCollection(); | ||
ConfigureServices(serviceCollection); | ||
serviceProvider = serviceCollection.BuildServiceProvider(); | ||
} | ||
|
||
private void ConfigureServices(ServiceCollection services) | ||
{ | ||
services.AddHttpClient<RxHttpClient>(); | ||
|
||
services.AddConsumer<TheMovieDatabaseConsumer>(http => | ||
{ | ||
http.BaseAddress = new Uri(@"https://api.themoviedb.org/3/"); | ||
}) | ||
.AddTransient<ConsumersTests>(); | ||
} | ||
|
||
public T Get<T>() | ||
{ | ||
return this.serviceProvider.GetService<T>(); | ||
} | ||
|
||
} | ||
} |
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