public MeetupClientFixture() { var configuration = new ConfigurationBuilder() .AddEnvironmentVariables() .Build(); var servicesCollection = new ServiceCollection(); servicesCollection.AddSingleton <IConfiguration>(configuration); var registry = servicesCollection.AddPolicyRegistry(); registry.Add("retry", Policy <HttpResponseMessage> .Handle <HttpRequestException>() .OrResult(r => r.StatusCode == HttpStatusCode.InternalServerError) .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(2))); servicesCollection .AddHttpClient <MeetupClient>(); // .AddPolicyHandlerFromRegistry("retry"); var serviceProvider = servicesCollection.BuildServiceProvider(); MeetupClient = serviceProvider.GetService <MeetupClient>(); }
public static async Task <HttpResponseMessage> Published(this MeetupClient @this) { await @this.Create(); await @this.UpdateLocation(); await @this.UpdateSeats(); await @this.UpdateTime(); return(await @this.Publish()); }
public static async Task TestCase( this MeetupClient @this, Func <MeetupClient, Task <HttpResponseMessage> > command, Action <HttpResponseMessage> assertResponse = null, Action <Meetup> assert = null) { assert = assert ?? (_ => { }); var response = await command(@this); assertResponse(response); await @this.Get(id); }
public MeetupClientFixture() { var configuration = new ConfigurationBuilder() .AddEnvironmentVariables() .Build(); var servicesCollection = new ServiceCollection(); servicesCollection.AddSingleton <IConfiguration>(configuration); servicesCollection.AddHttpClient <MeetupClient>(); var serviceProvider = servicesCollection.BuildServiceProvider(); MeetupClient = serviceProvider.GetService <MeetupClient>(); }
private static async Task Test <TResponse>( this MeetupClient @this, Func <MeetupClient, Task <HttpResponseMessage> > command, Action <HttpResponseMessage> assertResponse, Action <TResponse> assert, Func <Guid, Task <TResponse> > get) { assert = assert ?? (_ => { }); var response = await command(@this); assertResponse(response); var readModel = await get(id); assert(readModel); }
public static Task <HttpResponseMessage> Publish(this MeetupClient @this) => @this.Publish(id);
public static Task <HttpResponseMessage> Create(this MeetupClient @this) { id = Guid.NewGuid(); return(@this.Create(id, title)); }
public static async Task <Meetup> Get(this MeetupClient @this) => await @this.Get(id);
public static Task <HttpResponseMessage> UpdateTime(this MeetupClient @this) => @this.UpdateTime(id, start, start.AddHours(2));
public static Task TestAttendantsCase( this MeetupClient @this, Func <MeetupClient, Task <HttpResponseMessage> > command, Action <HttpResponseMessage> assertResponse = null, Action <Attendants> assert = null) => Test(@this, command, assertResponse, assert, @this.GetAttendants);
public static Task <HttpResponseMessage> UpdateSeats(this MeetupClient @this) => @this.UpdateSeats(id, numberOfSeats);
public MeetupTests(MeetupClientFixture fixture) { _client = fixture.MeetupClient; }
public static Task <HttpResponseMessage> RejectRSVP(this MeetupClient @this, Guid memberId, DateTime rejectedAt) => @this.RejectRSVP(id, memberId, rejectedAt);
public static Task <HttpResponseMessage> AcceptRSVP(this MeetupClient @this, Guid memberId, DateTime acceptedAt) => @this.AcceptRSVP(id, memberId, acceptedAt);
public static Task <HttpResponseMessage> Cancel(this MeetupClient @this) => @this.Cancel(id);
public static Task <HttpResponseMessage> UpdateLocation(this MeetupClient @this) => @this.UpdateLocation(id, location);
public static Task <HttpResponseMessage> Close(this MeetupClient @this) => @this.Close(id);
public AttendantsTest(MeetupClientFixture fixture) { _client = fixture.MeetupClient; }