public async Task ShouldCreateScheduleWhenRequested() { var workloadItems = new List <WorkloadItem> { Any.Instance <WorkloadItem>(), Any.Instance <WorkloadItem>() }; var maintenanceWindowServiceLocation = new ServiceLocation { Location = new Uri("http://localhost:5678") }; _mockServer.Given( Request.Create().UsingGet().WithPath("/MaintenanceWindowService")) .RespondWith( Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindowServiceLocation)); var maintenanceWindows = Any.Instance <MaintenanceWindow>(); _mockServer.Given( Request.Create().UsingGet().WithPath("/Planned")) .RespondWith( Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindows)); var httpClient = new HttpClient(); var scheduleWebApiClient = new ScheduleClient(httpClient) { BaseUrl = ScheduleWebApiBaseUrl }; var result = await scheduleWebApiClient.CreateScheduleAsync(workloadItems); result.Should().NotBe(Guid.Empty); }
public async Task ShouldRetrieveCreatedSchedule() { var workloadItems = new List <WorkloadItem> { new WorkloadItem { Identifier = Guid.NewGuid(), DurationInHours = 7 }, new WorkloadItem { Identifier = Guid.NewGuid(), DurationInHours = 3 } }; var maintenanceWindowServiceLocation = new ServiceLocation { Location = new Uri("http://localhost:5678") }; _mockServer.Given( Request.Create().UsingGet().WithPath("/MaintenanceWindowService")) .RespondWith( Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindowServiceLocation)); var maintenanceWindows = new MaintenanceWindow { LengthInHours = 5 }; _mockServer.Given( Request.Create().UsingGet().WithPath("/Planned")) .RespondWith( Response.Create().WithSuccess().WithBodyAsJson(maintenanceWindows)); var httpClient = new HttpClient(); var scheduleWebApiClient = new ScheduleClient(httpClient) { BaseUrl = ScheduleWebApiBaseUrl }; var scheduleId = await scheduleWebApiClient.CreateScheduleAsync(workloadItems); var result = await scheduleWebApiClient.GetScheduleByIdAsync(scheduleId); result.Count.Should().Be(2); result.Should().Contain(x => x.Identifier == workloadItems[0].Identifier && x.Order == 2); result.Should().Contain(x => x.Identifier == workloadItems[1].Identifier && x.Order == 1); }