Skip to content

Commit

Permalink
Added passing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Oct 11, 2010
1 parent 9d3ace8 commit 455fec4
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
88 changes: 88 additions & 0 deletions Raven.Client.Tests/Bugs/UsingStartsWith.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Linq;
using Raven.Client.Indexes;
using Xunit;

namespace Raven.Client.Tests.Bugs
{
public class UsingStartsWith : LocalClientTest
{
[Fact]
public void DefaultIndexingBehaviourDoesNotAllowStartsWith()
{
using (var store = this.NewDocumentStore())
{
var index = new IndexDefinition<Blog, BlogTagItem>()
{
Map = docs => from doc in docs
from tag in doc.Tags
select new
{
tag.Name
},
Reduce = results => from result in results
group result by result.Name into g
select new
{
Name = g.Key,
Count = g.Count()
}

}.ToIndexDefinition(store.Conventions);

store.DatabaseCommands.PutIndex("TagInfo", index);


using (var session = store.OpenSession())
{
var newBlog = new Blog()
{
Tags = new[]{
new BlogTag() { Name = "SuperCallaFragalisticExpealadocious" }
}
};
session.Store(newBlog);
session.SaveChanges();

var result = session.Query<BlogTagItem>("TagInfo")
.Customize(x => x.WaitForNonStaleResults())
.Where(x => x.Name.StartsWith("Su"))
.FirstOrDefault();

Assert.Null(result);
}
}
}

public class BlogTagItem
{
public string Name { get; set; }
public int Count { get; set; }
}

public class Blog
{
public string Title
{
get;
set;
}

public string Category
{
get;
set;
}

public BlogTag[] Tags
{
get;
set;
}
}

public class BlogTag
{
public string Name { get; set; }
}
}
}
1 change: 1 addition & 0 deletions Raven.Client.Tests/Raven.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Compile Include="Bugs\QueryingByNegative.cs" />
<Compile Include="Bugs\QueryingFromIndex.cs" />
<Compile Include="Bugs\QueryWithPercentageSign.cs" />
<Compile Include="Bugs\UsingStartsWith.cs" />
<Compile Include="Indexes\AnalyzerUtil.cs" />
<Compile Include="Indexes\UsingCustomLuceneAnalyzer.cs" />
<Compile Include="LocalClientTest.cs" />
Expand Down

0 comments on commit 455fec4

Please sign in to comment.