Created
December 5, 2012 12:26
-
-
Save damianh/4215137 to your computer and use it in GitHub Desktop.
RavenDB Contains Query Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ContainsQueryTests : IDisposable | |
| { | |
| private readonly IDocumentStore _documentStore; | |
| public ContainsQueryTests() | |
| { | |
| _documentStore = new EmbeddableDocumentStore {RunInMemory = true}.Initialize(); | |
| using (IDocumentSession session = _documentStore.OpenSession()) | |
| { | |
| session.Store(new TestDocument | |
| { | |
| Id = "Doc1", | |
| Text = "ATestString1" | |
| }); | |
| session.Store(new TestDocument | |
| { | |
| Id = "Doc2", | |
| Text = "ATestString2" | |
| }); | |
| session.SaveChanges(); | |
| } | |
| } | |
| [Fact] | |
| public void Contains_query_should_return_results() | |
| { | |
| using (IDocumentSession session = _documentStore.OpenSession()) | |
| { | |
| var results = session.Query<TestDocument>() | |
| .Where(x => x.Text.In("*Test*")) | |
| .ToList(); | |
| Assert.Equal(2, results.Count); | |
| } | |
| } | |
| [Fact] | |
| public void Contains_query_using_Lucene_syntax_should_return_results() | |
| { | |
| using (IDocumentSession session = _documentStore.OpenSession()) | |
| { | |
| var results = session.Advanced.LuceneQuery<TestDocument>() | |
| .Where("Text: *Test*") | |
| .ToList(); | |
| Assert.Equal(2, results.Count); | |
| } | |
| } | |
| public void Dispose() | |
| { | |
| _documentStore.Dispose(); | |
| } | |
| public class TestDocument | |
| { | |
| public string Id { get; set; } | |
| public string Text { get; set; } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment