Skip to content

Instantly share code, notes, and snippets.

@felipeleusin
Last active December 11, 2015 05:29
Show Gist options
  • Save felipeleusin/4552842 to your computer and use it in GitHub Desktop.
Save felipeleusin/4552842 to your computer and use it in GitHub Desktop.
Raven AsyncDocumentSession not generating Id after calling Store. [Update] In case anyone stumbles here apparently, this by design as replied in this issue: http://issues.hibernatingrhinos.com/issue/RavenDB-834
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Raven.Tests.Helpers;
using Xunit;
namespace Raven.Tests
{
public class User
{
public string Id { get; set; }
public string Name { get; set; }
}
public class AsyncSessionTests : RavenTestBase
{
[Fact]
public async Task CannotGenerateIdAfterStoreOnlyAfterSaveChanges()
{
using (var store = NewDocumentStore())
{
using (var session = store.OpenAsyncSession())
{
var user = new User() {Name = "fulano"};
session.Store(user);
Assert.NotNull(user.Id);
await session.SaveChangesAsync();
}
using (var session = store.OpenAsyncSession())
{
var user = await session.LoadAsync<User>(1);
Assert.NotNull(user);
Assert.Equal(user.Id, "users/1");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment