예제 #1
0
        public void IndexNewDocument()
        {
            SearchCls s = new SearchCls();
            Product   p = new Product();

            p.Id           = new[] { "100" };
            p.InStock      = new[] { true };
            p.Manufacturer = new[] { "Samsung" };
            p.price        = new[] { new Decimal(38000.00) };
            p.categories   = new[] { "Electronics", "Entertainment" };
            p.ProductName  = new[] { "Telivision" };
            int actualstatus               = s.AddtoIndex(p);
            int expectedstatus             = 0;
            SolrQueryResults <Product> res = s.searchProd("ProdName", "Television");

            Assert.AreEqual(expectedstatus, actualstatus);
            if (res != null)
            {
                Assert.AreEqual(res.Count, 1);
            }
            else
            {
                Assert.Fail();
            }
        }
예제 #2
0
        //   [TestMethod]
        public void TestDeleteNewlyAddedDoc()
        {
            string    prodtosearch   = "Television";
            int       expectedstatus = 0;
            SearchCls s      = new SearchCls();
            int       status = s.DeleteFromIndex("ProdName", prodtosearch);

            Console.WriteLine(status);
            Assert.AreEqual(status, expectedstatus);
            SolrQueryResults <Product> res = s.searchProd("ProdName", "Television");

            Assert.AreEqual(res.Count, 0);
        }
예제 #3
0
        //    [TestMethod]
        public void TestSearchExistingDoc()
        {
            string    prodtosearch     = "SampleProd";
            int       expectedrescount = 1;
            SearchCls s = new SearchCls();
            SolrQueryResults <Product> res = s.searchProd("ProdName", prodtosearch);
            int actual = 0;

            if (res != null)
            {
                actual = res.Count;
                Assert.AreEqual(expectedrescount, actual);
            }
            Assert.Fail();
        }