Created
January 18, 2013 12:54
-
-
Save felipeleusin/4564384 to your computer and use it in GitHub Desktop.
Raven example using property-based Id
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Raven.Tests.Helpers; | |
using Xunit; | |
namespace ClassLibrary4 | |
{ | |
public class User | |
{ | |
public string Id | |
{ | |
get { return "users/" + Email.ToLowerInvariant(); } | |
} | |
public string Email { get; set; } | |
public string Name { get; set; } | |
} | |
public class UserAsyncTests : RavenTestBase | |
{ | |
[Fact] | |
public async Task CanLoadAsync() | |
{ | |
using (var store = NewDocumentStore()) | |
{ | |
using (var session = store.OpenAsyncSession()) | |
{ | |
session.Store(new User() {Name = "Foo", Email = "fulano@fulano.com"}); | |
await session.SaveChangesAsync(); | |
} | |
using (var session = store.OpenAsyncSession()) | |
{ | |
var user = await session.LoadAsync<User>("users/fulano@fulano.com"); | |
Assert.NotNull(user); | |
Assert.Equal(user.Id, "users/" + user.Email); | |
Assert.Equal("Foo", user.Name); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment