public void overwrite_behavior_with_props() { Guid originalVerion = Guid.Empty; var doc = new PropVersionedDoc(); using (var session = theStore.OpenSession()) { session.Store(doc); session.VersionFor(doc).ShouldBeNull(); session.SaveChanges(); originalVerion = doc.Version; } IDocumentSession session1 = null; IDocumentSession session2 = null; try { session1 = theStore.OpenSession(); session2 = theStore.OpenSession(new SessionOptions { ConcurrencyChecks = ConcurrencyChecks.Disabled }); var doc1 = session1.Load <PropVersionedDoc>(doc.Id); doc1.Version.ShouldBe(originalVerion); session1.VersionFor(doc1).ShouldBe(originalVerion); session1.Store(doc1); var doc2 = session2.Load <PropVersionedDoc>(doc.Id); session2.Store(doc2); // save via session1 session1.SaveChanges(); doc1.Version.ShouldNotBe(originalVerion); // overwrite successfully w/ session2 session2.SaveChanges(); doc2.Version.ShouldNotBe(originalVerion); doc2.Version.ShouldNotBe(doc1.Version); } finally { session1?.Dispose(); session2?.Dispose(); } }
public void versions_are_assigned_during_bulk_inserts_as_prop() { var docs = new PropVersionedDoc[100]; for (int i = 0; i < docs.Length; i++) { docs[i] = new PropVersionedDoc(); } theStore.BulkInsert(docs); foreach (var doc in docs) { doc.Version.ShouldNotBe(Guid.Empty); } using (var session = theStore.OpenSession()) { session.Query <PropVersionedDoc>().Count(d => d.Version != Guid.Empty).ShouldBe(100); } }