Last active
December 11, 2015 20:09
-
-
Save davidroberts63/4653491 to your computer and use it in GitHub Desktop.
RavenDB Embedded not storing object when querying for the same object type but none of that type object has been stored before. [NUnit]
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
[Test] | |
public void Session_should_store_object_after_querying_same_type_object_that_has_never_been_stored_before() | |
{ | |
// Arrange | |
// RavenDB from NUget package: RavenDB.Embedded 2.0.2230 | |
// Raven.Clien.Embedded.dll Product Version: 2.0.0 / 08aa244 | |
var ravenStore = new EmbeddableDocumentStore() { RunInMemory = true }; | |
ravenStore.Initialize(); | |
// Act | |
using (var session = ravenStore.OpenSession()) | |
{ | |
// Uncommenting the following line will still fail the test but then it will report 2 records instead of 0 as originally. | |
//session.Store(new SimplePoco { Name = "Some name" }); | |
var queryResult = session.Query<SimplePoco>().SingleOrDefault(s => s.Name == "Some name"); | |
if (queryResult == null) | |
{ | |
session.Store(new SimplePoco { Name = "John Doe" }); | |
} | |
session.SaveChanges(); | |
} | |
// Assert | |
using (var session = ravenStore.OpenSession()) | |
{ | |
var result = session.Query<SimplePoco>(); | |
Assert.AreEqual(1, result.Count()); | |
} | |
} | |
public class SimplePoco | |
{ | |
public string Name { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment