예제 #1
0
        internal async Task <(int, CancelPunchOutDto)> CreateValidCancelPunchOutDtoAsync(List <CreateParticipantsDto> participants, UserType userType = UserType.Planner)
        {
            var id = await InvitationsControllerTestsHelper.CreateInvitationAsync(
                userType,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                InvitationLocation,
                DisciplineType.DP,
                _invitationStartTime,
                _invitationEndTime,
                participants,
                _mcPkgScope,
                null);

            var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                id);

            var cancelPunchOutDto = new CancelPunchOutDto
            {
                RowVersion = invitation.RowVersion
            };

            return(id, cancelPunchOutDto);
        }
        public static async Task <string> CancelPunchOutAsync(
            UserType userType,
            string plant,
            int id,
            CancelPunchOutDto dto,
            HttpStatusCode expectedStatusCode  = HttpStatusCode.OK,
            string expectedMessageOnBadRequest = null)
        {
            var bodyPayload = new
            {
                dto.RowVersion
            };

            var serializePayload = JsonConvert.SerializeObject(bodyPayload);
            var content          = new StringContent(serializePayload, Encoding.UTF8, "application/json");
            var response         = await TestFactory.Instance.GetHttpClient(userType, plant)
                                   .PutAsync($"{Route}/{id}/Cancel", content);

            await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest);

            if (expectedStatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            return(await response.Content.ReadAsStringAsync());
        }