Exemplo 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>();
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        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);
        }
Exemplo 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>();
        }
Exemplo 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);
        }
Exemplo n.º 6
0
 public static Task <HttpResponseMessage> Publish(this MeetupClient @this) => @this.Publish(id);
Exemplo n.º 7
0
 public static Task <HttpResponseMessage> Create(this MeetupClient @this)
 {
     id = Guid.NewGuid();
     return(@this.Create(id, title));
 }
Exemplo n.º 8
0
 public static async Task <Meetup> Get(this MeetupClient @this) => await @this.Get(id);
Exemplo n.º 9
0
 public static Task <HttpResponseMessage> UpdateTime(this MeetupClient @this) =>
 @this.UpdateTime(id, start, start.AddHours(2));
Exemplo 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);
Exemplo n.º 11
0
 public static Task <HttpResponseMessage> UpdateSeats(this MeetupClient @this) =>
 @this.UpdateSeats(id, numberOfSeats);
Exemplo n.º 12
0
 public MeetupTests(MeetupClientFixture fixture)
 {
     _client = fixture.MeetupClient;
 }
Exemplo n.º 13
0
 public static Task <HttpResponseMessage> RejectRSVP(this MeetupClient @this, Guid memberId, DateTime rejectedAt) =>
 @this.RejectRSVP(id, memberId, rejectedAt);
Exemplo n.º 14
0
 public static Task <HttpResponseMessage> AcceptRSVP(this MeetupClient @this, Guid memberId, DateTime acceptedAt) =>
 @this.AcceptRSVP(id, memberId, acceptedAt);
Exemplo n.º 15
0
 public static Task <HttpResponseMessage> Cancel(this MeetupClient @this) => @this.Cancel(id);
Exemplo n.º 16
0
 public static Task <HttpResponseMessage> UpdateLocation(this MeetupClient @this) =>
 @this.UpdateLocation(id, location);
Exemplo n.º 17
0
 public static Task <HttpResponseMessage> Close(this MeetupClient @this) => @this.Close(id);
Exemplo n.º 18
0
 public AttendantsTest(MeetupClientFixture fixture)
 {
     _client = fixture.MeetupClient;
 }