Beispiel #1
0
        public static Dictionary <string, object> GenerateProperties(
            FieldType fieldType,
            Label label             = Label.Min,
            OptionCount optionCount = OptionCount.Zero,
            string optionAlias      = "",
            Caption caption         = Caption.Missing,
            Search search           = Search.Missing,
            Match match             = Match.Missing,
            Web web             = Web.Missing,
            Highlight highlight = Highlight.Missing,
            Require require     = Require.Missing,
            SelectionDefault selectionDefault = SelectionDefault.Missing)
        {
            var optionInfos = GetOptionInfos(optionAlias);
            var properties  = new Dictionary <string, object>
            {
                [PropertyName.SType.GetEnumStringValue()] = (int)fieldType,
                [PropertyName.Label.GetEnumStringValue()] = LabelMapperValue[label],
                [PropertyName.Id.GetEnumStringValue()]    = optionInfos.FirstOrDefault().Key,
                [PropertyName.DType.GetEnumStringValue()] = (int)DTypeMapper[fieldType],
                [PropertyName.Count.GetEnumStringValue()] = (int)optionCount
            };

            CaptionMapperValue[caption](properties);
            SearchMapperValue[search](properties);
            MatchMapperValue[match](properties);
            WebMapperValue[web](properties);
            HighlightMapperValue[highlight](properties);
            RequireMapperValue[require](properties);
            SelectionDefaultMapper[selectionDefault](optionInfos.FirstOrDefault().Value, properties);
            return(properties);
        }
Beispiel #2
0
 private void Start()
 {
     optionCountIFCmpt = OptionCount.GetComponent <InputField>();
     optionCountIFCmpt.onEndEdit.AddListener(delegate
     {
         InstantiateDrive();
     });
 }
        public void TestSearchOptionCount(OptionCount optionCount)
        {
            OptionManager optionHandler            = new OptionManager();
            Dictionary <string, string> requestDic = new Dictionary <string, string>()
            {
                ["count"] = ValidCountMapper[optionCount].ToString(),
            };
            var response = optionHandler.SearchOption(requestDic);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response.Result, PrIs.Not.Null.And.Not.Empty);
            if (optionCount != OptionCount.All)
            {
                PrAssert.That(response.Result, Has.Count.LessThanOrEqualTo(ValidCountMapper[optionCount]), "The response result has more item then the expected count");
            }
        }
        public void CreateValidOptionalParamsTests(
            ResourceId resourceId,
            Alias alias,
            Label label,
            Caption caption,
            Search search,
            Match match,
            Web web,
            Highlight highlight,
            Require require,
            SelectionDefault selectionDefault,
            OptionCount optionCount)
        {
            // Get option alias
            var optionAlias = GetOptionsAlias()[new Random().Next(GetOptionsAlias().Count)];
            // Generate properties
            var properties = GenerateProperties(Commons.FieldTypeAPI, label, optionCount, optionAlias, caption, search, match, web, highlight, require, selectionDefault);
            // Generate request
            var request = GenerateRequest(Parameters.Create, GenerateCreateInfos(resourceId, properties, alias));

            // Execute test
            ExecuteCreateTest(request.ToJson());
        }
        public void TestSearchOptionIdLevelCount(ValidOptionId optionId, int optionLevel, OptionCount optionCount)
        {
            OptionManager optionHandler            = new OptionManager();
            Dictionary <string, string> requestDic = new Dictionary <string, string>(RequestOptionSearch);

            ValidIdMapper[optionId](requestDic, OptionCreator.Data.Id);
            requestDic["level"] = optionLevel.ToString();
            requestDic["count"] = ValidCountMapper[optionCount].ToString();
            var response = optionHandler.SearchOption(requestDic);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response.Result, PrIs.Not.Null.And.Not.Empty);
            PrAssert.That(response.Result.Select(r => r.Id), Has.Exactly(1).EqualTo(OptionCreator.Data.Id), "The expected option cannot be found!");
        }
        public void TestSearchOptionAliasLevelCount(ValidOptionAlias optionAlias, int optionLevel, OptionCount optionCount)
        {
            OptionManager optionHandler = new OptionManager();
            string        expectedAlias = ValidAliasMapper[optionAlias];
            var           response      = optionHandler.SearchOption(expectedAlias, level: optionLevel, count: ValidCountMapper[optionCount]);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response.Result, PrIs.Not.Null.And.Not.Empty);
            PrAssert.That(response.Result.Select(r => r.Alias), Has.Exactly(1).EqualTo(expectedAlias), "The expected option cannot be found!");
        }
        public void CreateValidRequireParamsTests(ResourceId resourceId, Label label, string optionAlias, OptionCount optionCount)
        {
            // Generate properties
            var properties = GenerateProperties(Commons.FieldTypeAPI, label, optionCount, optionAlias);
            // Generate request
            var request = GenerateRequest(Parameters.Create, GenerateCreateInfos(resourceId, properties));

            // Execute test
            ExecuteCreateTest(request.ToJson());
        }
Beispiel #8
0
        public void UpdateValidRequireParamsTests(ResourceId resourceId, FieldTestType fieldTestType, Label label, string optionAlias, OptionCount optionCount)
        {
            var properties = GenerateProperties(Commons.FieldTypeAPI, label, optionCount, optionAlias);
            var fieldId    = fieldTestType == FieldTestType.UserDefine ? PrepareUserField.Data[resourceId].FirstOrDefault() : PrepareAppField.Data[resourceId].FirstOrDefault();
            var request    = GenerateRequest(Parameters.Update, GenerateUpdateInfos(resourceId, fieldId, properties));

            ExecuteUpdateTest(request.ToJson(), fieldId, properties);
        }