Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding passing tests

  • Loading branch information...
commit 1da7c414a49010ea8559d73e1477a22d101a79f9 1 parent a0ae5a1
@ayende ayende authored
Showing with 102 additions and 0 deletions.
  1. +102 −0 Raven.Tests/MailingList/bhiku.cs
View
102 Raven.Tests/MailingList/bhiku.cs
@@ -0,0 +1,102 @@
+// -----------------------------------------------------------------------
+// <copyright file="bhiku.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+// -----------------------------------------------------------------------
+using System;
+using System.Linq;
+using Raven.Client.Indexes;
+using Raven.Client.Linq.Indexing;
+using Xunit;
+
+namespace Raven.Tests.MailingList
+{
+ public class Bhiku : RavenTest
+ {
+ [Fact]
+ public void CanUseBoost_StartsWith()
+ {
+ using (var store = NewDocumentStore())
+ {
+ using (var session = store.OpenSession())
+ {
+ session.Store(new Student { FirstName = "David", LastName = "Globe" });
+ session.Store(new Student { FirstName = "Tyson", LastName = "David" });
+ session.Store(new Student { FirstName = "David", LastName = "Jason" });
+ session.SaveChanges();
+ }
+
+ new Student_ByName().Execute(store);
+
+ using (var session = store.OpenSession())
+ {
+ var students = session.Advanced.LuceneQuery<Student>()
+ .WaitForNonStaleResults()
+ .WhereStartsWith("FirstName", "David").Boost(3)
+ .WhereStartsWith("LastName", "David")
+ .ToList();
+
+ Assert.Equal(3, students.Count);
+
+ Assert.Equal("students/1", students[0].Id);
+ Assert.Equal("students/3", students[1].Id);
+ Assert.Equal("students/2", students[2].Id);
+ }
+ }
+ }
+
+ [Fact]
+ public void CanUseBoost_Equal()
+ {
+ using (var store = NewDocumentStore())
+ {
+ using (var session = store.OpenSession())
+ {
+ session.Store(new Student { FirstName = "David", LastName = "Globe" });
+ session.Store(new Student { FirstName = "Tyson", LastName = "David" });
+ session.Store(new Student { FirstName = "David", LastName = "Jason" });
+ session.SaveChanges();
+ }
+
+ new Student_ByName().Execute(store);
+
+ using (var session = store.OpenSession())
+ {
+ var queryable = session.Query<Student, Student_ByName>()
+ .Customize(x => x.WaitForNonStaleResults())
+ .Where(x => x.FirstName == ("David") || x.LastName == ("David"));
+ var students = queryable
+ .ToList();
+
+ Assert.Equal(3, students.Count);
+
+ Assert.Equal("students/1", students[0].Id);
+ Assert.Equal("students/3", students[1].Id);
+ Assert.Equal("students/2", students[2].Id);
+ }
+ }
+ }
+
+ public class Student
+ {
+ public string Id { get; set; }
+ public string FirstName { get; set; }
+ public string LastName { get; set; }
+ public DateTime DateOfBirth { get; set; }
+ }
+
+ public class Student_ByName : AbstractIndexCreationTask<Student>
+ {
+ public Student_ByName()
+ {
+ Map = students => from s in students
+ select new
+ {
+ FirstName = s.FirstName.Boost(6),
+ s.LastName,
+ s.DateOfBirth,
+ };
+ }
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.