コード例 #1
0
ファイル: TestDocument.cs プロジェクト: VirtueMe/ravendb
		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);
		}
コード例 #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);
        }