示例#1
0
 public void AddingFieldIncreasesFieldCount()
 {
     var doc = new Document();
     var fi = new FieldOptions(StoreOptions.STORED, IndexOptions.Analyzed, TermVectorOptions.STORED);
     var field = new Field("Test",fi, new FieldSource<string>("Test Field Source"));
     doc.Add(field);
     Verify.That(doc.Count).IsEqualTo(1);
 }
示例#2
0
        public void FindAllByNameReturnsOnlyExpectedFields()
        {
            var doc = new Document();
            var fi = new FieldOptions(StoreOptions.STORED, IndexOptions.Analyzed, TermVectorOptions.STORED);
            var dummyField = new Field("Dummy", fi, new FieldSource<string>("Dummy Field"));

            var field1 = new Field("Test", fi, new FieldSource<string>("Test Field Source1"));
            var field2 = new Field("Test", fi, new FieldSource<string>("Test Field Source2"));

            doc.Add(dummyField);
            doc.Add(field1);
            doc.Add(field2);

            var result = doc.FindAllByName("Test");
            Verify.That(doc.Count).Equals(3);
            Verify.That(result).IsACollectionThat().Count().IsEqualTo(2);
        }
示例#3
0
        public void FindByNameReturnEmptyListIfNoMatchingField()
        {
            var doc = new Document();
            var result1 = doc.FindAllByName("Not Found");
            var fi = new FieldOptions(StoreOptions.STORED, IndexOptions.Analyzed, TermVectorOptions.STORED);
            var field1 = new Field("Test", fi, new FieldSource<string>("Test Field Source1"));
            doc.Add(field1);
            var result2 = doc.FindAllByName("Not Found");

            Verify.That(result1).IsACollectionThat().Count().IsEqualTo(0);
            Verify.That(result2).IsACollectionThat().Count().IsEqualTo(0);
        }
示例#4
0
        public void FindByNameReturnsNullIfNoMatchingField()
        {
            var doc = new Document();
            var result1 = doc.FindByName("No Found");
            var fi = new FieldOptions(StoreOptions.STORED, IndexOptions.Analyzed, TermVectorOptions.STORED);
            var field1 = new Field("Test", fi, new FieldSource<string>("Test Field Source"));
            doc.Add(field1);
            var result2 = doc.FindByName("No Found");

            Verify.That(result1).IsNull();
            Verify.That(result2).IsNull();
        }
示例#5
0
        public void FindByNameReturnsFirstAdded()
        {
            var doc = new Document();
            var fi = new FieldOptions(StoreOptions.STORED, IndexOptions.Analyzed, TermVectorOptions.STORED);
            var field1 = new Field("Test", fi, new FieldSource<string>("Test Field Source1"));
            var field2 = new Field("Test", fi, new FieldSource<string>("Test Field Source2"));
            doc.Add(field1);
            doc.Add(field2);

            Verify.That(doc.Count).Equals(2);
            Verify.That(doc.FindByName("Test")).IsTheSameObjectAs(field1);
        }