public void RouteParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          NumFilter($"{resource}.A_TestNumberScale0", OperatorType.Eq, 1234);

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
        private void PerformValidationTest(SearchRequest request, ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater)
        {
            requestUpdater(request, VerificationCases.AllAvailableCases[testCase]);

            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            if (expectedCode != PrivateApiResponseCode.OK)
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.ErrorCode((int)expectedCode).And.HttpCode(400));
            }
            else
            {
                PrAssert.That(response, PrIs.SuccessfulResponse <SearchResponse>());
                PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));
            }
        }
        public void EnumParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          BooleanFilter(OperatorType.And, new List <SearchFilter>
            {
                new SearchFilter
                {
                    Area       = "TEXT",
                    SplitMode  = "AND",
                    SearchType = "COND_FREEWORD",
                    Operator   = "IN",
                    Value      = SearchValue.CreateConst("TEST")
                },
                new SearchFilter
                {
                    Operator   = "=",
                    SearchType = "COND_DATE2",
                    Timezone   = "UTC",
                    Field      = new SearchField
                    {
                        Type  = "FIELD",
                        Route = $"{resource}.A_TestDate1"
                    },
                    Value = SearchValue.CreatePeriod("+P2Y", "DAY")
                }
            });

            request.Conditions.OrderBy.First().Direction = "DESC";
            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
        public void PeriodParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          DateFilter($"{resource}.A_TestDate1", OperatorType.Gt, "Asia/Tokyo", "P1M", null);

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
        public void TextParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilderWithRestrictions(resource).
                          TextFilter("A_TestSingleLineText", OperatorType.Eq, null, "test");

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
        public void ResourceRouteParamterValidationTest(ResourceId resource, VerificationCaseType testCase, PrivateApiResponseCode expectedCode, Action <SearchRequest, Func <string, string> > requestUpdater, string caseDescription)
        {
            var request = SearchRequestComposer.GetBuilder(resource, $"{(int)resource}")
                          .Filter(searchType: SearchRequestComposer.SearchTypeMap[SearchFilterType.NumOperator],
                                  field: $"{resource.ToString()}.P_Id",
                                  op: SearchRequestComposer.OperatorTypeMap[OperatorType.Eq],
                                  value: SearchValue.CreateConst("1234"));

            PerformValidationTest(request, resource, testCase, expectedCode, requestUpdater);
        }
Exemplo n.º 7
0
        private static TestCaseData GetTestCaseData(SearchRequest request, ResourceId resource, SearchFilterType searchType, string op, PrivateApiResponseCode expectedCode)
        {
            var testCaseData = new TestCaseData(request, resource, searchType, op, expectedCode);

            var nullApplicableOperators = new List <string>
            {
                "=",
                "!="
            };

            if (searchType == SearchFilterType.BoolAndOr || searchType == SearchFilterType.BoolNot)
            {
                testCaseData.Bug("39352");
            }
            if (searchType == SearchFilterType.Subquery ||
                searchType == SearchFilterType.FreeWord ||
                searchType == SearchFilterType.DateMinMax ||
                searchType == SearchFilterType.NumMinMax)
            {
                testCaseData.Bug("39354");
            }
            if ((searchType == SearchFilterType.Text && !nullApplicableOperators.Contains(op)) ||
                (searchType == SearchFilterType.DateIn && !nullApplicableOperators.Contains(op)) ||
                (searchType == SearchFilterType.NumOperator && !nullApplicableOperators.Contains(op)) ||
                (searchType == SearchFilterType.Date && !nullApplicableOperators.Contains(op)))
            {
                testCaseData.Bug("39355");
            }

            return(testCaseData);
        }
Exemplo n.º 8
0
        public void NullSearchValidationTest(SearchRequest request, ResourceId resource, SearchFilterType searchType, string operatorValue, PrivateApiResponseCode expectedCode)
        {
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            if (expectedCode == PrivateApiResponseCode.OK)
            {
                Assert.That(response, PrIs.SuccessfulResponse <SearchResponse>());
                PrAssert.That(response?.Result?.Status, PrIs.Not.Null.And.EqualTo("OK"));
            }
            else
            {
                Assert.That(response, PrIs.ErrorResponse().And.ErrorCode((int)expectedCode).And.HttpCode(400));
            }
        }
Exemplo n.º 9
0
        public void SearchTypeToFieldTypeTest(ResourceId resource, SearchFilterType filterType, FieldType fieldType, SearchRequest request, PrivateApiResponseCode expectedCode, string description)
        {
            var handler  = new DefaultManager();
            var response = handler.Send <SearchResponse>(request);

            if (expectedCode == PrivateApiResponseCode.OK)
            {
                Assert.That(response, PrIs.SuccessfulResponse <SearchResponse>());
            }
            else
            {
                Assert.That(response, PrIs.ErrorResponse().And.ErrorCode((int)expectedCode).And.HttpCode(400));
            }
        }