Esempio n. 1
0
        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);
        }
Esempio n. 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>();
        }
Esempio n. 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));
Esempio n. 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);
Esempio n. 11
0
 public static Task <HttpResponseMessage> UpdateSeats(this MeetupClient @this) =>
 @this.UpdateSeats(id, numberOfSeats);
Esempio n. 12
0
 public MeetupTests(MeetupClientFixture fixture)
 {
     _client = fixture.MeetupClient;
 }
Esempio n. 13
0
 public static Task <HttpResponseMessage> RejectRSVP(this MeetupClient @this, Guid memberId, DateTime rejectedAt) =>
 @this.RejectRSVP(id, memberId, rejectedAt);
Esempio n. 14
0
 public static Task <HttpResponseMessage> AcceptRSVP(this MeetupClient @this, Guid memberId, DateTime acceptedAt) =>
 @this.AcceptRSVP(id, memberId, acceptedAt);
Esempio n. 15
0
 public static Task <HttpResponseMessage> Cancel(this MeetupClient @this) => @this.Cancel(id);
Esempio n. 16
0
 public static Task <HttpResponseMessage> UpdateLocation(this MeetupClient @this) =>
 @this.UpdateLocation(id, location);
Esempio n. 17
0
 public static Task <HttpResponseMessage> Close(this MeetupClient @this) => @this.Close(id);
Esempio n. 18
0
 public AttendantsTest(MeetupClientFixture fixture)
 {
     _client = fixture.MeetupClient;
 }