Example #1
0
        public virtual void  TestBinaryField()
        {
            Document  doc        = new Document();
            Fieldable stringFld  = new Field("string", binaryVal, Field.Store.YES, Field.Index.NO);
            Fieldable binaryFld  = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal), Field.Store.YES);
            Fieldable binaryFld2 = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal2), Field.Store.YES);

            doc.Add(stringFld);
            doc.Add(binaryFld);

            Assert.AreEqual(2, doc.fields_ForNUnit.Count);

            Assert.IsTrue(binaryFld.IsBinary());
            Assert.IsTrue(binaryFld.IsStored());
            Assert.IsFalse(binaryFld.IsIndexed());
            Assert.IsFalse(binaryFld.IsTokenized());

            System.String binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(doc.GetBinaryValue("binary")));
            Assert.IsTrue(binaryTest.Equals(binaryVal));

            System.String stringTest = doc.Get("string");
            Assert.IsTrue(binaryTest.Equals(stringTest));

            doc.Add(binaryFld2);

            Assert.AreEqual(3, doc.fields_ForNUnit.Count);

            byte[][] binaryTests = doc.GetBinaryValues("binary");

            Assert.AreEqual(2, binaryTests.Length);

            binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[0]));
            System.String binaryTest2 = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[1]));

            Assert.IsFalse(binaryTest.Equals(binaryTest2));

            Assert.IsTrue(binaryTest.Equals(binaryVal));
            Assert.IsTrue(binaryTest2.Equals(binaryVal2));

            doc.RemoveField("string");
            Assert.AreEqual(2, doc.fields_ForNUnit.Count);

            doc.RemoveFields("binary");
            Assert.AreEqual(0, doc.fields_ForNUnit.Count);
        }
Example #2
0
		public virtual void  TestBinaryField()
		{
			Document doc = new Document();
			Fieldable stringFld = new Field("string", binaryVal, Field.Store.YES, Field.Index.NO);
			Fieldable binaryFld = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal), Field.Store.YES);
			Fieldable binaryFld2 = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal2), Field.Store.YES);
			
			doc.Add(stringFld);
			doc.Add(binaryFld);
			
			Assert.AreEqual(2, doc.fields_ForNUnit.Count);
			
			Assert.IsTrue(binaryFld.IsBinary());
			Assert.IsTrue(binaryFld.IsStored());
			Assert.IsFalse(binaryFld.IsIndexed());
			Assert.IsFalse(binaryFld.IsTokenized());
			
			System.String binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(doc.GetBinaryValue("binary")));
			Assert.IsTrue(binaryTest.Equals(binaryVal));
			
			System.String stringTest = doc.Get("string");
			Assert.IsTrue(binaryTest.Equals(stringTest));
			
			doc.Add(binaryFld2);
			
			Assert.AreEqual(3, doc.fields_ForNUnit.Count);
			
			byte[][] binaryTests = doc.GetBinaryValues("binary");
			
			Assert.AreEqual(2, binaryTests.Length);
			
			binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[0]));
			System.String binaryTest2 = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[1]));
			
			Assert.IsFalse(binaryTest.Equals(binaryTest2));
			
			Assert.IsTrue(binaryTest.Equals(binaryVal));
			Assert.IsTrue(binaryTest2.Equals(binaryVal2));
			
			doc.RemoveField("string");
			Assert.AreEqual(2, doc.fields_ForNUnit.Count);
			
			doc.RemoveFields("binary");
			Assert.AreEqual(0, doc.fields_ForNUnit.Count);
		}
Example #3
0
        private void AddFieldRow(string fieldName, Field f)
        {
            string feature;
            ListViewItem item = new ListViewItem("<" + fieldName + ">");

            if (f != null && f.IsIndexed()) feature = "+";
            else feature = " ";
            item.SubItems.Add(feature);

            if (f != null && f.IsTokenized()) feature = "+";
            else feature = " ";
            item.SubItems.Add(feature);

            if (f != null && f.IsStored()) feature = "+";
            else feature = " ";
            item.SubItems.Add(feature);

            if (f != null && f.IsTermVectorStored()) feature = "+";
            else feature = " ";
            item.SubItems.Add(feature);

            if (f != null)
                item.SubItems.Add(f.GetBoost().ToString("0.0####"));
            else item.SubItems.Add("");

            if (f != null)
                item.SubItems.Add(f.StringValue());
            else
            {
                item.SubItems.Add(_luke.resources.GetString("FieldNotAvailable"));
            }

            listDocFields.Items.Add(item);
        }