public void TestFetchAndStoreDefaultSchema()
        {
            // Get Default schema
            var getSchemaResult = Client.GetSearchSchema("_yz_default");

            Assert.True(getSchemaResult.IsSuccess, getSchemaResult.ErrorMessage);

            var defaultSchema = getSchemaResult.Value;

            defaultSchema.Name.ShouldNotBeNull();
            defaultSchema.Content.ShouldNotBeNull();

            // Store as new schema
            var          newSchemaName    = "test_schema" + Random.Next();
            const string randomComment    = "<!-- Random Comment -->";
            var          newSchemaContent = defaultSchema.Content + randomComment;
            var          newSchema        = new SearchSchema(newSchemaName, newSchemaContent);

            var putSchemaResult = Client.PutSearchSchema(newSchema);

            putSchemaResult.IsSuccess.ShouldBeTrue(putSchemaResult.ErrorMessage);

            // Fetch new schema and compare
            var getSchemaResult2 = Client.GetSearchSchema(newSchemaName);
            var fetchedNewSchema = getSchemaResult2.Value;

            Assert.AreEqual(newSchemaName, fetchedNewSchema.Name);
            Assert.AreNotEqual(defaultSchema.Content, fetchedNewSchema.Content); // Should differ by the added comment
            Assert.AreEqual(newSchemaContent, fetchedNewSchema.Content);
            Assert.IsTrue(fetchedNewSchema.Content.Contains(randomComment));
        }
示例#2
0
        //DataSet ds;
        #endregion


        public DataSet SearchDetails(SearchSchema objSearchSchema)
        {
            SqlConnection objConn = SQLHelper.OpenConnection();

            try
            {
                var param = new SqlParameter[]
                {
                    new SqlParameter("@LangID", objSearchSchema.LangID == 0 ? 0  : objSearchSchema.LangID),
                    new SqlParameter("@Keyword", objSearchSchema.Keyword == null ? (object)DBNull.Value : objSearchSchema.Keyword),
                };

                using (DataSet ds = SQLHelper.ExecuteDataset(objConn, null, CommandType.StoredProcedure, "spSearchSite", param))
                {
                    return(ds);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                SQLHelper.CloseConnection(objConn);
            }
        }
        public void CustomSchema()
        {
            var xml    = File.ReadAllText("cartoons.xml");
            var schema = new SearchSchema("cartoons", xml);
            var rslt   = client.PutSearchSchema(schema);

            CheckResult(rslt);
        }
示例#4
0
 public DataSet SearchDetails(SearchSchema objSearchSchema)
 {
     try
     {
         ds = objSearchDAL.SearchDetails(objSearchSchema);
         return(ds);
     }
     catch (Exception e)
     {
         return(null);
     }
     finally
     {
         ds = null;
     }
 }
        public void SetUpFixture()
        {
            if (!File.Exists(blogPostSchemaFileName))
            {
                Console.WriteLine("Writing {0} in {1}", blogPostSchemaFileName, Environment.CurrentDirectory);
                var    req    = WebRequest.Create(blogPostSchema);
                var    rsp    = req.GetResponse();
                var    stream = rsp.GetResponseStream();
                string line   = string.Empty;
                using (var writer = new StreamWriter(blogPostSchemaFileName))
                {
                    using (var rdr = new StreamReader(stream))
                    {
                        while ((line = rdr.ReadLine()) != null)
                        {
                            writer.WriteLine(line);
                        }
                    }
                }
            }

            base.CreateClient();

            var getSchemaResult = client.GetSearchSchema("blog_post_schema");

            if (!getSchemaResult.IsSuccess)
            {
                var schemaXml = File.ReadAllText(blogPostSchemaFileName);
                var schema    = new SearchSchema(blogPostSchemaName, schemaXml);
                var rslt      = client.PutSearchSchema(schema);
                CheckResult(rslt);

                WaitForSearch();

                var idx = new SearchIndex("blog_posts", "blog_post_schema");
                rslt = client.PutSearchIndex(idx);
                CheckResult(rslt);
            }
        }