예제 #1
0
        public void TestCreateOptionalParameterValid(ResourceId resource, Properties.Alias alias, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Length length, Properties.Default deft, Properties.Height height)
        {
            var handler    = new DefaultManager();
            var properties = TextHelpers.GenerateWithRequireProperties(Defines.FieldTypeApi, caption, search, match, web, highlight, require, length, deft, height);
            var request    = TextHelpers.GenerateCreateRequest(resource, alias, properties);
            var response   = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssert.That(response.Result.Id, PrIs.Not.Null.Or.Not.Empty);

            var result = (new FieldManager()).GetFieldDetails(response.Result.Id);

            //Clearn up
            CommonHelpers.DeleteField(new List <Guid> {
                response.Result.Id
            });
            //Verify
            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Id, PrIs.EqualTo(response.Result.Id));
            TextHelpers.VerifyProperties(result.Result.Values.SingleOrDefault().Value.Properties, properties);
        }
예제 #2
0
        public static Dictionary <string, object> GeneratePropertiesWithoutRequired(FieldType fType, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Length length = Properties.Length.Missing, Properties.Default deft = Properties.Default.Null, Properties.Height height = Properties.Height.Missing)
        {
            var properties = new Dictionary <string, object>();

            CommonMapperValue.CaptionMapperValue[caption](properties);
            CommonMapperValue.SearchMapperValue[search](properties);
            CommonMapperValue.MatchMapperValue[match](properties);
            CommonMapperValue.WebMapperValue[web](properties);
            CommonMapperValue.HighlightMapperValue[highlight](properties);
            CommonMapperValue.RequireMapperValue[require](properties);
            LenghtMapperValue[length](fType, properties);
            DefaultMapperValue[deft](fType, properties);
            if (fType == FieldType.MultiLinesText)
            {
                HeightMapperValue[height](properties);
            }
            return(properties);
        }
예제 #3
0
        public void TestUpdateOptionalParameterValid(ResourceId resource, TextHelpers.FieldTypes fType, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Length length, Properties.Default deft)
        {
            var guid = TextHelpers.Guid[fType](resource, FieldsCreator, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().First());

            //Update lenght to avoid missing lenght case if other tests effect to preparing data
            TextHelpers.UpdateLenghtProperty(resource, Defines.FieldTypeApi, guid);

            var handler  = new DefaultManager();
            var props    = TextHelpers.GeneratePropertiesWithoutRequired(Defines.FieldTypeApi, caption, search, match, web, highlight, require, length, deft);
            var request  = TextHelpers.GenerateUpdateRequest(resource, guid.ToString(), props);
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));

            //Verify
            var result = (new FieldManager()).GetFieldDetails(guid);

            TextHelpers.VerifyProperties(result.Result.Values.SingleOrDefault().Value.Properties, props);
        }
예제 #4
0
 public static Dictionary <string, object> GenerateWithRequireProperties(FieldType fType, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Length length = Properties.Length.Missing, Properties.Default deft = Properties.Default.Null, Properties.Height height = Properties.Height.Missing)
 {
     return(RequiredProperties(fType).Union(GeneratePropertiesWithoutRequired(fType, caption, search, match, web, highlight, require, length, deft, height)).ToDictionary(k => k.Key, v => v.Value));
 }