Skip to content

Instantly share code, notes, and snippets.

@JohannesRudolph
Created July 11, 2013 12:31
Show Gist options
  • Save JohannesRudolph/5975037 to your computer and use it in GitHub Desktop.
Save JohannesRudolph/5975037 to your computer and use it in GitHub Desktop.
RavenDb Session.Advanced.MarkReadOnly bug? repro
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