public static PrivateData <Dictionary <object, Guid> > PrepareTwoUserField(int numberFieldType) { return(new PrivateData <Dictionary <object, Guid> >( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var result = new Dictionary <object, Guid>(); var properties = GenerateRequiredProperties(numberFieldType, Properties.Label.Max, FileType.Bmp); HeightMapperValue[Properties.Height.Max](properties); foreach (ResourceId resource in Utils.Resources()) { for (int i = 0; i < 2; i++) { var createResponse = handler.CreateField(resource, properties); PrAssume.That(createResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create field"); result.Add($"{resource}{i}", createResponse.Result.Id); } } return result; }); }, (session, test, res) => Task.Run(() => { foreach (var item in res) { var handler = new FieldManager(); handler.DeleteField(item.Value); } }))); }
public static PrivateData <Guid> PrepareUserField() { return(new PrivateData <Guid>( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var result = new Dictionary <ResourceId, Guid>(); var properties = new Dictionary <string, object> { ["s.type"] = (int)FieldType.Number, ["d.label.ja"] = "Test Number Field" };; var createResponse = handler.CreateField(ResourceId.Client, properties); PrAssume.That(createResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create field"); return createResponse.Result.Id; }); }, (session, test, res) => Task.Run(() => { var handler = new FieldManager(); handler.DeleteField(res); }))); }
public void NotDeletableSystemFields(string alias) { var fieldHandler = new FieldManager(); var response = fieldHandler.DeleteField(alias); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.NotPermitted)); }
public void NotDeletableApplicationFields(ResourceId resourceId) { var fieldHandler = new FieldManager(); var response = fieldHandler.DeleteField($"{resourceId.ToString()}.{ApplicationFields}"); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.NotPermitted)); }
public static PrivateData <Dictionary <object, Guid> > PrepareTwoUserFieldInvalidCase(int numberFieldType, int indexCreated, int indexDeleted) { return(new PrivateData <Dictionary <object, Guid> >( (session, test) => { return Task.Run(() => { var handler = new FieldManager(); var result = new Dictionary <object, Guid>(); var properties = GenerateRequiredProperties(numberFieldType, Properties.Label.Max); foreach (ResourceId resource in Utils.Resources()) { var createResponse = handler.CreateField(resource, properties); PrAssume.That(createResponse, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK), "Can not Create field"); result.Add($"{resource}{indexCreated}", createResponse.Result.Id); var createSecondResponse = handler.CreateField(resource, properties); PrAssume.That(createSecondResponse, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK), "Can not Create field"); result.Add($"{resource}{indexDeleted}", createSecondResponse.Result.Id); var deleteResponse = handler.DeleteField(createSecondResponse.Result.Id); PrAssume.That(deleteResponse, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.NoContent), "Can not delete field"); } return result; }); }, (session, test, res) => Task.Run(() => { foreach (var item in res) { var handler = new FieldManager(); handler.DeleteField(item.Value); } }))); }
public void DeletableUserFields(ResourceId resourceId) { var fieldHandler = new FieldManager(); var response = fieldHandler.DeleteField(FieldCreator.Data[resourceId.ToString()].Field.ToAlias()); PrAssert.That(response, PrIs.SuccessfulResponse(), $"Delete an user field operation was not successful. HTTP response code is {response.HttpStatusCode}"); VerifyFieldNotExist(FieldCreator.Data[resourceId.ToString()].Field.ToAlias()); }
public static void ExecuteCreateTest(string request) { var defaultManager = new DefaultManager(); var result = defaultManager.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.POST); PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create field"); PrAssert.That(result.Result.Id, PrIs.Not.Null.Or.Empty, "Empty result"); // Check field id is created var fieldManager = new FieldManager(); var readResult = fieldManager.GetFieldDetails(result.Result.Id); PrAssert.That(readResult, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not read field details"); PrAssert.That(readResult.Result.Values.SingleOrDefault().Value.Id, PrIs.EqualTo(result.Result.Id), "Field id is not matched"); // Clean data test fieldManager.DeleteField(result.Result.Id); }