This file contains hidden or 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
version: '3.3' | |
services: | |
web: | |
build: . | |
image: demo-api | |
container_name: aspnet-core-webapi | |
restart: always | |
deploy: | |
replicas: 1 |
This file contains hidden or 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
version: '3.3' | |
services: | |
web: | |
build: . | |
image: demo-api | |
container_name: aspnet-core-webapi | |
restart: always | |
environment: | |
- MONGO_URI=mongodb://mongodb:27017/db |
This file contains hidden or 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
class _CollectionsListState extends State<CollectionsList> { | |
final _scrollController = ScrollController(); | |
final _scrollThreshold = 200.0; | |
Completer<void> _refreshCompleter; | |
@override | |
void initState() { | |
_refreshCompleter = Completer<void>(); | |
_scrollController.addListener(_onScroll); | |
widget._collectionsBloc.dispatch(CollectionsFetchEvent()); |
This file contains hidden or 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
public override void ConfigureServices(IServiceCollection services) | |
{ | |
//Configurando policy de timeout padrão | |
var timeoutPolicy = Policy.TimeoutAsync<HttpResponseMessage>(10); | |
//Add services | |
services.AddHttpClient<ApiService>() | |
.AddPolicyHandler(GetRetryPolicy()) | |
.AddPolicyHandler(timeoutPolicy); |
This file contains hidden or 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
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
namespace ConsoleApp | |
{ | |
public class ApiService | |
{ | |
private readonly HttpClient _client; | |
public ApiService(HttpClient client) |
This file contains hidden or 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
[Fact] | |
public void MultpleOf_ShouldThrowExpcetionWhenYIsNegative() | |
{ | |
Should.Throw<ArgumentException>(() => | |
{ | |
Helpers.IsMultipleOf(-3, 9); | |
}); | |
} |
This file contains hidden or 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
public static bool IsMultipleOf(int y, int x) | |
{ | |
//Chek if value is negative | |
if (x < 0 || y < 0) | |
throw new ArgumentException("Essa operação só é possível com números naturais."); | |
//Check possible DivisionByZero | |
if (y == 0) | |
throw new ArgumentException("O múltiplo deve ser maior do que 0.", nameof(y)); |
This file contains hidden or 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
using Shouldly; | |
using Xunit; | |
namespace Problems.Tests | |
{ | |
public class ProblemsSolutionTests | |
{ | |
/// <summary> | |
/// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
// Find the sum of all the multiples of 3 or 5 below 1000. |
This file contains hidden or 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
using System.Linq; | |
.... | |
public static int SumOfMultiples(int max, params int[] possibleMultiples) | |
{ | |
int sum = 0; | |
//Validate if the number is MultipleOf, then sum it | |
for (int value = 1; value < max; value++) |
This file contains hidden or 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
[Theory] | |
[InlineData(3, 1)] | |
[InlineData(3, 5)] | |
public void Multiple_ShouldFail(int y, int x) | |
{ | |
Helpers.IsMultipleOf(y, x).ShouldBeFalse(); | |
} |