Last active
August 29, 2015 14:27
-
-
Save brunomlopes/d0c809917e91f8450284 to your computer and use it in GitHub Desktop.
Test case for bug? Tested on 3.0.3751-Unstable and 3.0.3690
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
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Raven.Client; | |
using Raven.Client.Embedded; | |
using Raven.Client.Indexes; | |
using Raven.Client.Linq; | |
using Raven.Tests.Helpers; | |
using Xunit; | |
namespace ClassLibrary1 | |
{ | |
public class IsInTriggersSyncFromAsync : RavenTestBase | |
{ | |
private readonly EmbeddableDocumentStore _store; | |
public IsInTriggersSyncFromAsync() | |
{ | |
_store = NewDocumentStore(); | |
new Index().Execute(_store); | |
using (var session = _store.OpenSession()) | |
{ | |
session.Store(new Entity | |
{ | |
Id = "solo", | |
Tokens = new List<string> | |
{ | |
"ABC", | |
"DEF" | |
} | |
}); | |
session.SaveChanges(); | |
} | |
} | |
[Fact] | |
public async Task IsInTriggersSyncFromAsyncException() | |
{ | |
using (var session = _store.OpenAsyncSession()) | |
{ | |
var queryToken = "ABC"; | |
var entity = await session.Query<Entity, Index>() | |
.Customize(q => q.WaitForNonStaleResults()) | |
.Where(e => e.Id == "solo" && queryToken.In(e.Tokens)) | |
.FirstOrDefaultAsync(); | |
Assert.NotNull(entity); | |
Assert.Equal("solo", entity.Id); | |
} | |
} | |
[Fact] | |
public async Task WithoutIsInItWorks() | |
{ | |
using (var session = _store.OpenAsyncSession()) | |
{ | |
var queryToken = "ABC"; | |
var entity = await session.Query<Entity, Index>() | |
.Customize(q => q.WaitForNonStaleResults()) | |
.Where(e => e.Id == "solo") | |
.FirstOrDefaultAsync(); | |
Assert.NotNull(entity); | |
Assert.Equal("solo", entity.Id); | |
} | |
} | |
} | |
internal class Entity | |
{ | |
public string Id { get; set; } | |
public List<string> Tokens { get; set; } | |
} | |
internal class Index : AbstractIndexCreationTask<Entity> | |
{ | |
public Index() | |
{ | |
Map = entities => from entity in entities | |
select new | |
{ | |
entity.Tokens | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment