Ejemplo n.º 1
0
        private void ClearClosedConferencesForUser(TestApiManager api)
        {
            var response          = api.GetConferencesForTodayJudge(_username);
            var todaysConferences = RequestHelper.Deserialise <List <ConferenceForJudgeResponse> >(response.Content);

            if (todaysConferences == null)
            {
                return;
            }

            foreach (var conference in todaysConferences)
            {
                var hearingId = GetTheHearingIdFromTheConference(api, conference.Id);

                if (HearingHasNotBeenDeletedAlready(api, hearingId) && !hearingId.Equals(Guid.Empty))
                {
                    DeleteTheHearing(api, hearingId);
                }

                if (ConferenceHasNotBeenDeletedAlready(api, conference.Id))
                {
                    DeleteTheConference(api, hearingId, conference.Id);
                }
            }
        }
        private void UserShouldNotHaveAnswers(TestApiManager api)
        {
            var response = api.GetSuitabilityAnswers(_username);
            var answers  = RequestHelper.Deserialise <List <PersonSuitabilityAnswerResponse> >(response.Content);

            if (answers?.Count > 0)
            {
                throw new DataException($"user with username '{_username}' has {answers.Count} previous answer(s) saved");
            }
        }
        private static void ParticipantsShouldExistInTheDb(TestApiManager api, Guid hearingId, List <UserDto> users)
        {
            var hearingResponse = api.GetHearing(hearingId);
            var hearing         = RequestHelper.Deserialise <HearingDetailsResponse>(hearingResponse.Content);

            hearing.Should().NotBeNull();
            foreach (var user in users.Where(user => user.UserType != UserType.CaseAdmin && user.UserType != UserType.VideoHearingsOfficer))
            {
                hearing.Participants.Any(x => x.LastName.Equals(user.LastName)).Should().BeTrue();
            }
        }
Ejemplo n.º 4
0
        private static Guid GetTheHearingIdFromTheConference(TestApiManager api, Guid conferenceId)
        {
            var response = api.GetConferenceByConferenceId(conferenceId);

            if (!response.IsSuccessful)
            {
                return(Guid.Empty);
            }
            var conference = RequestHelper.Deserialise <ConferenceDetailsResponse>(response.Content);

            return(conference.HearingId);
        }
Ejemplo n.º 5
0
        private void ClearHearingsForUser(TestApiManager api)
        {
            var response = api.GetHearingsByUsername(_username);
            var hearings = RequestHelper.Deserialise <List <HearingDetailsResponse> >(response.Content);

            if (hearings == null)
            {
                return;
            }
            foreach (var hearing in hearings)
            {
                DeleteTheHearing(api, hearing.Id);
            }
        }
Ejemplo n.º 6
0
        private void ClearHearingsForUser(TestApiManager api)
        {
            var response = api.GetHearingsByUsername(_username);
            var hearings = RequestHelper.Deserialise <List <HearingDetailsResponse> >(response.Content);

            if (hearings == null)
            {
                return;
            }

            var ids = hearings.Select(x => x.GroupId).Distinct().ToList();

            foreach (var id in ids.Where(x => x.HasValue))
            {
                DeleteTheHearing(api, id.Value);
            }
        }
        public static HearingDetailsResponse CreateHearing(TestApiManager api, List <UserDto> users)
        {
            var isWinger = users.Any(X => X.UserType == UserType.Winger);

            var hearingRequest = isWinger ? CreateHearingForWinger(users) : new HearingRequestBuilder()
                                 .WithUsers(users)
                                 .Build();

            var hearingResponse = api.CreateHearing(hearingRequest);

            hearingResponse.StatusCode.Should().Be(HttpStatusCode.Created);
            var hearing = RequestHelper.Deserialise <HearingDetailsResponse>(hearingResponse.Content);

            hearing.Should().NotBeNull();
            ParticipantsShouldExistInTheDb(api, hearing.Id, users);
            NUnit.Framework.TestContext.WriteLine($"Hearing created with Hearing Id {hearing.Id}");
            return(hearing);
        }
Ejemplo n.º 8
0
        private static bool HearingHasNotBeenDeletedAlready(TestApiManager api, Guid hearingId)
        {
            var response = api.GetHearing(hearingId);

            return(!response.StatusCode.Equals(HttpStatusCode.NotFound));
        }
Ejemplo n.º 9
0
        private static void DeleteTheHearing(TestApiManager api, Guid hearingId)
        {
            var response = api.DeleteHearing(hearingId);

            response.IsSuccessful.Should().BeTrue($"HearingDetails {hearingId} has been deleted. Status {response.StatusCode}. {response.Content}");
        }
Ejemplo n.º 10
0
 private static void DeleteTheConference(TestApiManager api, Guid hearingId, Guid conferenceId)
 {
     api.DeleteConference(hearingId, conferenceId);
 }
Ejemplo n.º 11
0
        private static bool ConferenceHasNotBeenDeletedAlready(TestApiManager api, Guid conferenceId)
        {
            var response = api.GetConferenceByConferenceId(conferenceId);

            return(!response.StatusCode.Equals(HttpStatusCode.NotFound));
        }
Ejemplo n.º 12
0
 public PollForParticipantStatus(TestApiManager api)
 {
     _api = api;
 }
Ejemplo n.º 13
0
 public PollForConferenceStatus(TestApiManager api)
 {
     _api = api;
 }