Skip to content

Instantly share code, notes, and snippets.

View alefcarlos's full-sized avatar
✌️
Focusing

Alef Carlos alefcarlos

✌️
Focusing
View GitHub Profile
version: '3.3'
services:
web:
build: .
image: demo-api
container_name: aspnet-core-webapi
restart: always
deploy:
replicas: 1
version: '3.3'
services:
web:
build: .
image: demo-api
container_name: aspnet-core-webapi
restart: always
environment:
- MONGO_URI=mongodb://mongodb:27017/db
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());
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);
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace ConsoleApp
{
public class ApiService
{
private readonly HttpClient _client;
public ApiService(HttpClient client)
[Fact]
public void MultpleOf_ShouldThrowExpcetionWhenYIsNegative()
{
Should.Throw<ArgumentException>(() =>
{
Helpers.IsMultipleOf(-3, 9);
});
}
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));
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.
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++)
[Theory]
[InlineData(3, 1)]
[InlineData(3, 5)]
public void Multiple_ShouldFail(int y, int x)
{
Helpers.IsMultipleOf(y, x).ShouldBeFalse();
}