Last active
May 10, 2016 12:58
-
-
Save PureKrome/00e7f2be557e94911fb6b23119639e3e to your computer and use it in GitHub Desktop.
RavenDb repo with breaking code.
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.Linq; | |
using Raven.Tests.Helpers; | |
using Xunit; | |
namespace ClassLibrary1 | |
{ | |
public class Class1 : RavenTestBase | |
{ | |
private static async Task CreateUsersAsync(IAsyncDocumentSession session) | |
{ | |
var user1 = new User {Name = "Jane"}; | |
user1.OfficesIds.Add("office/1"); | |
user1.OfficesIds.Add("office/2"); | |
var user2 = new User {Name = "Bill"}; | |
user2.OfficesIds.Add("office/1"); | |
user2.OfficesIds.Add("office/3"); | |
await session.StoreAsync(user1); | |
await session.StoreAsync(user2); | |
} | |
[Fact] | |
public async Task PleaseWorkForMe() | |
{ | |
// Arrange. | |
User user; | |
var query = new SomeQuery | |
{ | |
UserId = 1 | |
}; | |
var store = NewDocumentStore(); | |
WaitForIndexing(store); | |
using (var session = store.OpenAsyncSession()) | |
{ | |
await CreateUsersAsync(session); | |
await session.SaveChangesAsync(); | |
var userId = $"users/{query.UserId}"; | |
// Act. | |
user = await session.Query<User>() | |
.Where(x => x.Id == userId) | |
.Where(i => i.OfficesIds.Any(o => o.In(query.OfficeIds))) | |
//.Where(i => i.OfficesIds.ContainsAny(query.OfficeIds)) | |
.FirstOrDefaultAsync(); | |
} | |
// Assert. | |
Assert.Equal("Jane", user.Name); | |
} | |
} | |
public class User | |
{ | |
public string Id { get; set; } | |
public string Name { get; set; } | |
public IList<string> OfficesIds { get; set; } = new List<string>(); | |
} | |
public class SomeQuery | |
{ | |
public int UserId { get; set; } | |
public IEnumerable<string> OfficeIds { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment