public void When_rollback_called_submit_changes_not_store_changes() { using (var session = new RavenDbSession(_documentStore)) { session.Save(new Employee { Name = "John Smith" }); session.Save(new Employee { Name = "John Smith Clone1" }); session.Save(new Employee { Name = "John Smith Clone2" }); session.CancelChanges(); try { session.SubmitChanges(); } catch (InvalidOperationException) { } } using (var session = new RavenDbSession(_documentStore)) { session.Query <Employee>().Should().HaveCount(0); } }
public static RavenDbSession OpenStorageSession() { var storageSession = new RavenDbSession(CurrentSession); if (!storageSession.IsInitialized) { storageSession.ForcedInitialize(); } return storageSession; }
public static void DisposeSessions() { if (HasCurrentSession) { CurrentStorageSession.Dispose(); _currentStorageSession = null; _currentSession = null; } }
public static RavenDbSession OpenStorageSession() { var storageSession = new RavenDbSession(CurrentSession); if (!storageSession.IsInitialized) { storageSession.ForcedInitialize(); } return(storageSession); }
public void When_rollback_called_and_submit_changes_is_not_called_no_one_exceptions_occured() { using (var session = new RavenDbSession(_documentStore)) { session.Save(new Employee { Name = "John Smith" }); session.Save(new Employee { Name = "John Smith Clone1" }); session.Save(new Employee { Name = "John Smith Clone2" }); session.CancelChanges(); } }
public void When_rollback_called_IsRolledBack_flag_is_true() { using (var session = new RavenDbSession(_documentStore)) { session.Save(new Employee { Name = "John Smith" }); session.Save(new Employee { Name = "John Smith Clone1" }); session.Save(new Employee { Name = "John Smith Clone2" }); session.CancelChanges(); session.IsCancelled.Should().BeTrue(); } }
public void When_rollback_called_invocation_of_submit_changes_should_failed() { using (var session = new RavenDbSession(_documentStore)) { session.Save(new Employee { Name = "John Smith" }); session.Save(new Employee { Name = "John Smith Clone1" }); session.Save(new Employee { Name = "John Smith Clone2" }); session.CancelChanges(); Action action = () => session.SubmitChanges(); action.ShouldThrow <InvalidOperationException>(); } }
public void When_Submit_changes_is_not_called_no_changes_is_stored() { using (var session = new RavenDbSession(_documentStore)) { session.Save(new Employee { Name = "John Smith" }); session.Save(new Employee { Name = "John Smith Clone1" }); session.Save(new Employee { Name = "John Smith Clone2" }); } using (var session = new RavenDbSession(_documentStore)) { session.Query <Employee>().Should().HaveCount(0); } }
/// <summary> /// 清理 /// </summary> public void Clean() { RavenDbSession.FreeCommandInstanceCall(); RavenDbSession.FreeQueryInstanceCall(); }
public void SetupSession() { _session = new RavenDbSession(_documentStore); }