Created
July 11, 2013 12:31
-
-
Save JohannesRudolph/5975037 to your computer and use it in GitHub Desktop.
RavenDb Session.Advanced.MarkReadOnly bug? repro
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 Xunit; | |
namespace Raven.Tests.Bugs | |
{ | |
public class MarkReadOnly : RavenTest | |
{ | |
public class Widget | |
{ | |
public string Id { get; set; } | |
public string Property { get; set; } | |
} | |
[Fact] | |
public void MarkReadOnlyIsNotPersistent() | |
{ | |
const string widgetId = "widgets/1"; | |
using (var store = NewDocumentStore()) | |
{ | |
using (var session = store.OpenSession()) | |
{ | |
var entity = new Widget() { Id = widgetId, Property = "A" }; | |
session.Store(entity); | |
session.SaveChanges(); | |
} | |
// mark readonly | |
using (var session = store.OpenSession()) | |
{ | |
var entity = session.Load<Widget>( widgetId ); | |
session.Advanced.MarkReadOnly( entity ); | |
session.SaveChanges(); | |
} | |
// try changing | |
using (var session = store.OpenSession()) | |
{ | |
var entity = session.Load<Widget>( widgetId ); | |
entity.Property = "B"; | |
Assert.True( session.Advanced.HasChanged( entity ) ); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment