Patches are only reflected in document loads after session is disposed and re-opened in unit tests/embedded store.

6 views
Skip to first unread message

Roman

unread,
Oct 25, 2016, 1:46:18 AM10/25/16
to RavenDB - 2nd generation document database
Is there a flag or something to get this to work correctly? 

See this unit tests that fails on the first assert:


using Microsoft.VisualStudio.TestTools.UnitTesting;
using Raven.Tests.Helpers;
using Raven.Abstractions.Data;
using Raven.Json.Linq;

namespace BriefBox.UnitTest.RavenTests
{
    [TestClass]
    public class RavenDbGenericTests : RavenTestBase
    {
        public class TestEntity
        {
            public TestEntity()
            {
                Children = new TestEntity[0];
            }

            public string Id { get; set; }
            public string Value { get; set; }
            public TestEntity[] Children { get; set; }
        }

        [TestMethod]
        public void Test()
        {
            TestEntity testEntity;

            using (var store = NewDocumentStore(configureStore: ds=> ds.Configuration.Storage.Voron.AllowOn32Bits = true))
            {
                using (var session = store.OpenSession())
                {
                    testEntity = new TestEntity() { Value = "Roman1" };
                    session.Store(testEntity);
                    session.SaveChanges();

                    session.Advanced.DocumentStore.DatabaseCommands.Patch(testEntity.Id,
                        new PatchRequest[]
                        {
                            new PatchRequest()
                            {
                                 Name = "Children",
                                 Value = RavenJObject.FromObject(new TestEntity() { Value = "Added Child" }),
                                 Type = PatchCommandType.Add,
                            }
                        });

                    var result = session.Load<TestEntity>(testEntity.Id);
                    Assert.AreEqual(1, result.Children.Length); //BLOWS UP HERE
                }

                using (var session = store.OpenSession())
                {
                    var result = session.Load<TestEntity>(testEntity.Id);
                    Assert.AreEqual(1, result.Children.Length); //Does not fail if above is commented out
                }
            }
        }
    }
}


Thank you in advance
Reply all
Reply to author
Forward
0 new messages