forked from ravendb/ravendb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Refactor embedded testing to a different class
- Loading branch information
Fitzchak Yitzchaki
committed
Apr 3, 2012
1 parent
04364c4
commit c6c7964
Showing
3 changed files
with
151 additions
and
147 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="SuggestionsLazy.cs" company="Hibernating Rhinos LTD"> | ||
// Copyright (c) Hibernating Rhinos LTD. All rights reserved. | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
using System.Linq; | ||
using Raven.Abstractions.Indexing; | ||
using Raven.Client.Document; | ||
using Raven.Client.Linq; | ||
using Raven.Tests.Bugs; | ||
using Xunit; | ||
|
||
namespace Raven.Tests.Suggestions | ||
{ | ||
public class SuggestionsLazy : LocalClientTest | ||
{ | ||
[Fact] | ||
public void UsingLinq() | ||
{ | ||
using(GetNewServer()) | ||
using (var store = new DocumentStore{Url = "http://localhost:8079"}.Initialize()) | ||
{ | ||
store.DatabaseCommands.PutIndex("Test", new IndexDefinition | ||
{ | ||
Map = "from doc in docs select new { doc.Name }", | ||
}); | ||
using (var s = store.OpenSession()) | ||
{ | ||
s.Store(new User { Name = "Ayende" }); | ||
s.Store(new User { Name = "Oren" }); | ||
s.SaveChanges(); | ||
|
||
s.Query<User>("Test").Customize(x => x.WaitForNonStaleResults()).ToList(); | ||
} | ||
|
||
using (var s = store.OpenSession()) | ||
{ | ||
var oldRequests = s.Advanced.NumberOfRequests; | ||
|
||
var suggestionQueryResult = s.Query<User>("test") | ||
.Where(x => x.Name == "Oren") | ||
.SuggestLazy(); | ||
|
||
Assert.Equal(oldRequests, s.Advanced.NumberOfRequests); | ||
Assert.Equal(1, suggestionQueryResult.Value.Suggestions.Length); | ||
Assert.Equal("oren", suggestionQueryResult.Value.Suggestions[0]); | ||
|
||
Assert.Equal(oldRequests + 1, s.Advanced.NumberOfRequests); | ||
} | ||
} | ||
} | ||
} | ||
} |