Example #1
0
        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);
            }
        }
Example #2
0
 public static RavenDbSession OpenStorageSession()
 {
     var storageSession = new RavenDbSession(CurrentSession);
     if (!storageSession.IsInitialized)
     {
         storageSession.ForcedInitialize();
     }
     return storageSession;
 }
Example #3
0
 public static void DisposeSessions()
 {
     if (HasCurrentSession)
     {
         CurrentStorageSession.Dispose();
         _currentStorageSession = null;
         _currentSession = null;
     }
 }
Example #4
0
 public static void DisposeSessions()
 {
     if (HasCurrentSession)
     {
         CurrentStorageSession.Dispose();
         _currentStorageSession = null;
         _currentSession        = null;
     }
 }
Example #5
0
        public static RavenDbSession OpenStorageSession()
        {
            var storageSession = new RavenDbSession(CurrentSession);

            if (!storageSession.IsInitialized)
            {
                storageSession.ForcedInitialize();
            }
            return(storageSession);
        }
Example #6
0
        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();
            }
        }
Example #7
0
        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();
            }
        }
Example #8
0
        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>();
            }
        }
Example #9
0
        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);
            }
        }
Example #10
0
 /// <summary>
 /// 清理
 /// </summary>
 public void Clean()
 {
     RavenDbSession.FreeCommandInstanceCall();
     RavenDbSession.FreeQueryInstanceCall();
 }
 public void SetupSession()
 {
     _session = new RavenDbSession(_documentStore);
 }