コード例 #1
0
        public void ValidGetCustomActionTest(CustomActionTestData.ValidUrl url, CustomActionTestData.ValidLabel validLabel, CustomActionTestData.ValidLabelValue validLabelValue, CustomActionTestData.ValidPlaceValue validPlaceValue)
        {
            var createRequest = CreateCustomActionTests.GetCreateRequest(CustomActionTestData.ValidUrlMapper[url],
                                                                         CustomActionTestData.ValidLabelMapper[validLabel](CustomActionTestData.ValidLabelValueMapper[validLabelValue]),
                                                                         CustomActionTestData.ValidPlaceValueMapper[validPlaceValue]);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod());

            if (validLabel == CustomActionTestData.ValidLabel.BothEnJa)
            {
                PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action");
                var allCustomAction = hanlder.GetAllCustomActions();
                CreateCustomActionTests.DeleteCustomAction(response.Result.Id);
                PrAssert.That(allCustomAction.Result[response.Result.Id].Url, PrIs.EqualTo(CustomActionTestData.ValidUrlMapper[url]), "The url is not as expected");
                PrAssert.That(allCustomAction.Result[response.Result.Id].Label.EnUs.Value, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.ValueParam]), "The En label value is not as expected");
                PrAssert.That(allCustomAction.Result[response.Result.Id].Label.Ja.Value, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.ValueParam]), "The Ja label value is not as expected");
                if (validLabelValue != CustomActionTestData.ValidLabelValue.MissingDefaultStringWithSpace && validLabelValue != CustomActionTestData.ValidLabelValue.MissingDefaultStringNoSpace)
                {
                    PrAssert.That(allCustomAction.Result[response.Result.Id].Label.Ja.Default, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.DefaultParam]), "The Ja label default is not as expected");
                    PrAssert.That(allCustomAction.Result[response.Result.Id].Label.EnUs.Default, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.DefaultParam]), "The En label default is not as expected");
                }
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action Successfully");
            }
        }
コード例 #2
0
        public void ValidUpdateCustomActionTest(CustomActionTestData.ValidUrl url, CustomActionTestData.ValidLabel validLabel, CustomActionTestData.ValidLabelValue validLabelValue)
        {
            var updateRequest = GetUpdateRequest(PrepareData.Data.Id,
                                                 PrepareData.Data.LocalizedTextId,
                                                 CustomActionTestData.ValidUrlMapper[url],
                                                 CustomActionTestData.ValidLabelMapper[validLabel](CustomActionTestData.ValidLabelValueMapper[validLabelValue]));
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <UpdateCustomActionResponse>(updateRequest, HttpMethod.PUT.ToNetHttpMethod());

            if (validLabel == CustomActionTestData.ValidLabel.BothEnJa)
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not update custom action");
                var allCustomAction = hanlder.GetAllCustomActions();
                PrAssert.That(allCustomAction.Result[PrepareData.Data.Id].Url, PrIs.EqualTo(CustomActionTestData.ValidUrlMapper[url]), "The url is not as expected");
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create update custom action");
            }
        }
コード例 #3
0
        public void InvalidLabelValueUpdateCustomActionTest(CustomActionTestData.ValidLabel validLabel, string parameterName, CustomActionTestData.InvalidValue invalidValue)
        {
            var labelValue = new Dictionary <string, object>(CustomActionTestData.ValidLabelValueMapper[CustomActionTestData.ValidLabelValue.StringNoSpaceBoth]);

            CustomActionTestData.InvalidValueMapper[invalidValue](labelValue, parameterName);
            var updateRequest = GetUpdateRequest(PrepareData.Data.Id,
                                                 PrepareData.Data.LocalizedTextId,
                                                 CustomActionTestData.ValidUrlMapper[CustomActionTestData.ValidUrl.ExistingUrl],
                                                 new Dictionary <string, object>(CustomActionTestData.ValidLabelMapper[validLabel](labelValue)));
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <UpdateCustomActionResponse>(updateRequest, HttpMethod.PUT.ToNetHttpMethod());

            if (validLabel == CustomActionTestData.ValidLabel.BothEnJa && (invalidValue == CustomActionTestData.InvalidValue.Bignumber || invalidValue == CustomActionTestData.InvalidValue.Negative || invalidValue == CustomActionTestData.InvalidValue.Zero))
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action successfully");
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action successfully");
            }
        }
コード例 #4
0
        public void ValidCreateCustomActionTest(CustomActionTestData.ValidUrl url, CustomActionTestData.ValidLabel validLabel, CustomActionTestData.ValidLabelValue validLabelValue, CustomActionTestData.ValidPlaceValue validPlaceValue)
        {
            var createRequest = GetCreateRequest(CustomActionTestData.ValidUrlMapper[url],
                                                 CustomActionTestData.ValidLabelMapper[validLabel](CustomActionTestData.ValidLabelValueMapper[validLabelValue]),
                                                 CustomActionTestData.ValidPlaceValueMapper[validPlaceValue]);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod());

            if (validLabel == CustomActionTestData.ValidLabel.BothEnJa)
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action");
                PrAssert.That(response.Result.Id, PrIs.Not.Null.And.Not.Empty, "Can not create custom action");
                var allCustomAction = hanlder.GetAllCustomActions();
                PrAssert.That(allCustomAction.Result[response.Result.Id].Url, PrIs.EqualTo(CustomActionTestData.ValidUrlMapper[url]), "The url is not as expected");
                DeleteCustomAction(response.Result.Id);
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action successfully");
            }
        }
コード例 #5
0
        public void InvalidLabelValueCreateCustomActionTest(CustomActionTestData.ValidLabel validLabel, string parameterName, CustomActionTestData.InvalidValue invalidValue)
        {
            var labelValue = new Dictionary <string, object>(CustomActionTestData.ValidLabelValueMapper[CustomActionTestData.ValidLabelValue.StringNoSpaceBoth]);

            CustomActionTestData.InvalidValueMapper[invalidValue](labelValue, parameterName);
            var createRequest = GetCreateRequest(CustomActionTestData.ValidUrlMapper[CustomActionTestData.ValidUrl.ExistingUrl],
                                                 CustomActionTestData.ValidLabelMapper[validLabel](labelValue),
                                                 CustomActionTestData.ValidPlaceValueMapper[CustomActionTestData.ValidPlaceValue.Client]);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod());

            if (validLabel == CustomActionTestData.ValidLabel.BothEnJa && (invalidValue != CustomActionTestData.InvalidValue.Empty && invalidValue != CustomActionTestData.InvalidValue.MissingParam))
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action successfully");
                DeleteCustomAction(response.Result.Id);
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action successfully");
            }
        }