示例#1
0
        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!");
        }
示例#2
0
        public void TestSearchOptionAliasInvalidSelf(ValidOptionAlias optionAlias, InvalidOptionSelf optionSelf)
        {
            OptionManager optionHandler            = new OptionManager();
            Dictionary <string, string> requestDic = new Dictionary <string, string>()
            {
                ["alias"] = ValidAliasMapper[optionAlias],
                ["self"]  = InvalidSelfMapper[optionSelf],
            };
            var response = optionHandler.SearchOption(requestDic);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidValue).Or.ErrorCode((int)ResultCode.ValueRangeExceeded), $"Still able to search option with both alias = {optionAlias.ToString()} and self = {optionSelf.ToString()}");
        }
示例#3
0
        public void TestSearchOptionIdAlias(ValidOptionId optionId, ValidOptionAlias optionAlias)
        {
            OptionManager optionHandler            = new OptionManager();
            Dictionary <string, string> requestDic = new Dictionary <string, string>()
            {
                ["alias"] = ValidAliasMapper[optionAlias],
            };

            ValidIdMapper[optionId](requestDic, OptionCreater.Data.Id);

            var response = optionHandler.SearchOption(requestDic);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidParameter), $"Still able to search option with both id = {optionId.ToString()} and alias = {optionAlias.ToString()}");
        }
示例#4
0
        public void TestSearchOptionAliasSelf(ValidOptionAlias optionAlias, bool optionSelf)
        {
            OptionManager optionHandler = new OptionManager();
            string        expectedAlias = ValidAliasMapper[optionAlias];
            var           response      = optionHandler.SearchOption(expectedAlias, self: optionSelf);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            if (optionSelf)
            {
                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!");
            }
            else
            {
                PrAssert.That(response.Result, PrIs.Not.Null.And.Not.Empty);
                PrAssert.That(response.Result.SingleOrDefault(), Has.Count.EqualTo(0), "The prepared option is found although self = false!");
            }
        }