public async Task ShouldRetrieveCreatedSchedule()
        {
            var scheduleWebApiClient = new JsonServiceClient(ScheduleWebApiBaseUrl);

            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 workloadItems = new List <WorkloadItem>
            {
                new WorkloadItem
                {
                    Identifier      = Guid.NewGuid(),
                    DurationInHours = 7
                },
                new WorkloadItem
                {
                    Identifier      = Guid.NewGuid(),
                    DurationInHours = 3
                }
            };
            var createScheduleRequest = new CreateScheduleRequest
            {
                WorkloadItems = workloadItems
            };

            var createScheduleResponse = await scheduleWebApiClient.PostAsync(createScheduleRequest).ConfigureAwait(false);

            var getScheduleByIdRequest = new GetScheduleByIdRequest
            {
                ScheduleId = createScheduleResponse.Id
            };
            var getScheduleByIdResponse = await scheduleWebApiClient.GetAsync(getScheduleByIdRequest).ConfigureAwait(false);

            getScheduleByIdResponse.Schedule.Count.Should().Be(2);
            getScheduleByIdResponse.Schedule.Should().Contain(x => x.Identifier == workloadItems[0].Identifier &&
                                                              x.Order == 2);
            getScheduleByIdResponse.Schedule.Should().Contain(x => x.Identifier == workloadItems[1].Identifier &&
                                                              x.Order == 1);
        }
Пример #2
0
        public object Get(GetScheduleByIdRequest request)
        {
            _logger.LogInformation("Get schedule requested.");

            var response = new GetScheduleByIdResponse
            {
                Schedule = _scheduleStorage.ReadSchedule(request.ScheduleId)
            };

            return(response);
        }