コード例 #1
0
    public void StepThreeRS()
    {
      bool ErrorOccurred = false;

      QueryHelper<object, object> qh = QueryHelper<object, object>.GetHelper(CacheHelper.DCache);

      var qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService();

      int qryIdx = 0;

      foreach (QueryStrings qrystr in QueryStatics.ResultSetQueries)
      {
        if (qrystr.Category == QueryCategory.Unsupported)
        {
          Util.Log("Skipping query index {0} because it is unsupported.", qryIdx);
          qryIdx++;
          continue;
        }

        if (m_isPdx == true)
        {
          if (qryIdx == 2 || qryIdx == 3 || qryIdx == 4)
          {
            Util.Log("Skipping query index {0} for Pdx because it is function type.", qryIdx);
            qryIdx++;
            continue;
          }
        }

        Util.Log("Evaluating query index {0}. Query string {1}", qryIdx, qrystr.Query);

        Query<object> query = qs.NewQuery<object>(qrystr.Query);

        ISelectResults<object> results = query.Execute();

        int expectedRowCount = qh.IsExpectedRowsConstantRS(qryIdx) ?
          QueryStatics.ResultSetRowCounts[qryIdx] : QueryStatics.ResultSetRowCounts[qryIdx] * qh.PortfolioNumSets;

        if (!qh.VerifyRS(results, expectedRowCount))
        {
          ErrorOccurred = true;
          Util.Log("Query verify failed for query index {0}.", qryIdx);
          qryIdx++;
          continue;
        }

        ResultSet<object> rs = results as ResultSet<object>;

        foreach (object item in rs)
        {
          if (!m_isPdx)
          {
            Portfolio port = item as Portfolio;
            if (port == null)
            {
              Position pos = item as Position;
              if (pos == null)
              {
                string cs = item.ToString();
                if (cs == null)
                {
                  Util.Log("Query got other/unknown object.");
                }
                else
                {
                  Util.Log("Query got string : {0}.", cs);
                }
              }
              else
              {
                Util.Log("Query got Position object with secId {0}, shares {1}.", pos.SecId, pos.SharesOutstanding);
              }
            }
            else
            {
              Util.Log("Query got Portfolio object with ID {0}, pkid {1}.", port.ID, port.Pkid);
            }
          }
          else
          {
            PortfolioPdx port = item as PortfolioPdx;
            if (port == null)
            {
              PositionPdx pos = item as PositionPdx;
              if (pos == null)
              {
                string cs = item.ToString();
                if (cs == null)
                {
                  Util.Log("Query got other/unknown object.");
                }
                else
                {
                  Util.Log("Query got string : {0}.", cs);
                }
              }
              else
              {
                Util.Log("Query got Position object with secId {0}, shares {1}.", pos.secId, pos.getSharesOutstanding);
              }
            }
            else
            {
              Util.Log("Query got Portfolio object with ID {0}, pkid {1}.", port.ID, port.Pkid);
            }
          }
        }

        qryIdx++;
      }

      Assert.IsFalse(ErrorOccurred, "One or more query validation errors occurred.");
    }
コード例 #2
0
        public void StepThreePQRS()
        {
            bool ErrorOccurred = false;

            QueryHelper <object, object> qh = QueryHelper <object, object> .GetHelper(CacheHelper.DCache);

            var qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService();

            int qryIdx = 0;

            foreach (QueryStrings paramqrystr in QueryStatics.ResultSetParamQueries)
            {
                if (paramqrystr.Category == QueryCategory.Unsupported)
                {
                    Util.Log("Skipping query index {0} because it is unsupported.", qryIdx);
                    qryIdx++;
                    continue;
                }

                Util.Log("Evaluating query index {0}. {1}", qryIdx, paramqrystr.Query);

                Query <object> query = qs.NewQuery <object>(paramqrystr.Query);

                //Populate the parameter list (paramList) for the query.
                object[] paramList = new object[QueryStatics.NoOfQueryParam[qryIdx]];
                int      numVal    = 0;
                for (int ind = 0; ind < QueryStatics.NoOfQueryParam[qryIdx]; ind++)
                {
                    //Util.Log("NIL::PQRS:: QueryStatics.QueryParamSet[{0},{1}] = {2}", qryIdx, ind, QueryStatics.QueryParamSet[qryIdx][ind]);

                    try
                    {
                        numVal         = Convert.ToInt32(QueryStatics.QueryParamSet[qryIdx][ind]);
                        paramList[ind] = numVal;
                        //Util.Log("NIL::PQRS::361 Interger Args:: paramList[0] = {1}", ind, paramList[ind]);
                    }
                    catch (FormatException)
                    {
                        //Console.WriteLine("Param string is not a sequence of digits.");
                        paramList[ind] = (System.String)QueryStatics.QueryParamSet[qryIdx][ind];
                        //Util.Log("NIL::PQRS:: Interger Args:: routingObj[0] = {1}", ind, routingObj[ind].ToString());
                    }
                }

                ISelectResults <object> results = query.Execute(paramList);

                //Varify the result
                int expectedRowCount = qh.IsExpectedRowsConstantPQRS(qryIdx) ?
                                       QueryStatics.ResultSetPQRowCounts[qryIdx] : QueryStatics.ResultSetPQRowCounts[qryIdx] * qh.PortfolioNumSets;

                if (!qh.VerifyRS(results, expectedRowCount))
                {
                    ErrorOccurred = true;
                    Util.Log("Query verify failed for query index {0}.", qryIdx);
                    qryIdx++;
                    continue;
                }

                ResultSet <object> rs = results as ResultSet <object>;

                foreach (object item in rs)
                {
                    if (!m_isPdx)
                    {
                        Portfolio port = item as Portfolio;
                        if (port == null)
                        {
                            Position pos = item as Position;
                            if (pos == null)
                            {
                                string cs = item as string;
                                if (cs == null)
                                {
                                    Util.Log("Query got other/unknown object.");
                                }
                                else
                                {
                                    Util.Log("Query got string : {0}.", cs);
                                }
                            }
                            else
                            {
                                Util.Log("Query got Position object with secId {0}, shares {1}.", pos.SecId, pos.SharesOutstanding);
                            }
                        }
                        else
                        {
                            Util.Log("Query got Portfolio object with ID {0}, pkid {1}.", port.ID, port.Pkid);
                        }
                    }
                    else
                    {
                        PortfolioPdx port = item as PortfolioPdx;
                        if (port == null)
                        {
                            PositionPdx pos = item as PositionPdx;
                            if (pos == null)
                            {
                                string cs = item as string;
                                if (cs == null)
                                {
                                    Util.Log("Query got other/unknown object.");
                                }
                                else
                                {
                                    Util.Log("Query got string : {0}.", cs);
                                }
                            }
                            else
                            {
                                Util.Log("Query got PositionPdx object with secId {0}, shares {1}.", pos.secId, pos.getSharesOutstanding);
                            }
                        }
                        else
                        {
                            Util.Log("Query got PortfolioPdx object with ID {0}, pkid {1}.", port.ID, port.Pkid);
                        }
                    }
                }

                qryIdx++;
            }

            Assert.IsFalse(ErrorOccurred, "One or more query validation errors occurred.");
        }