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);
        }
Beispiel #4
0
        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>();
        }
Beispiel #5
0
        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));
Beispiel #10
0
 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);
Beispiel #12
0
 public MeetupTests(MeetupClientFixture fixture)
 {
     _client = fixture.MeetupClient;
 }
Beispiel #13
0
 public static Task <HttpResponseMessage> RejectRSVP(this MeetupClient @this, Guid memberId, DateTime rejectedAt) =>
 @this.RejectRSVP(id, memberId, rejectedAt);
Beispiel #14
0
 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);
Beispiel #18
0
 public AttendantsTest(MeetupClientFixture fixture)
 {
     _client = fixture.MeetupClient;
 }