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"); } }
public void ValidDeleteCustomActionTest() { var deleteRequest = GetDeleteRequest(PrepareData.Data.Id); var hanlder = new CustomActionManager(); var response = hanlder.CustomAction <object>(deleteRequest, HttpMethod.DELETE.ToNetHttpMethod()); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.NoContent), "Can not update custom action"); var allCustomAction = hanlder.GetAllCustomActions(); PrAssert.That(allCustomAction.Result.ContainsKey(PrepareData.Data.Id), PrIs.EqualTo(false), "The custom action is not deleted"); }
public void ValidDuplicateDeleteCustomActionTest(CustomActionTestData.DuplicateId duplicateParameter) { var deleteRequest = duplicateParameter == CustomActionTestData.DuplicateId.SameValue ? $"{{\"id\": {PrepareData.Data.Id}, \"id\": {PrepareData.Data.Id} }}" : $"{{\"id\": {PrepareData.Data.Id}, \"id\": 305 }}"; var hanlder = new CustomActionManager(); var response = hanlder.CustomAction <object>(deleteRequest, HttpMethod.DELETE.ToNetHttpMethod()); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.NoContent), "Can not update custom action"); var allCustomAction = hanlder.GetAllCustomActions(); PrAssert.That(allCustomAction.Result.ContainsKey(PrepareData.Data.Id), PrIs.EqualTo(false), "The custom action is not deleted"); }
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"); } }
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"); } }