Skip to content

Instantly share code, notes, and snippets.

@damianh
Created December 5, 2012 12:26
Show Gist options
  • Select an option

  • Save damianh/4215137 to your computer and use it in GitHub Desktop.

Select an option

Save damianh/4215137 to your computer and use it in GitHub Desktop.
RavenDB Contains Query Test
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