public void CanSetFlushModeToNever()
        {
            ArrangeRecords();

            using (var conversation = new ScopedConversation(ConversationFlushMode.Explicit))
            {
                BlogLazy blog;
                using (new ConversationalScope(conversation))
                {
                    blog        = BlogLazy.FindAll().First();
                    blog.Author = "Anonymous";
                    blog.Save();
                    BlogLazy.FindAll();                     // Triggers flushing if allowed
                }

                Assert.That(blog.Author, Is.EqualTo("Anonymous"));

                // Outside any ConversationalScope session-per-request is used
                Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Markus"));

                conversation.Flush();
            }

            Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Anonymous"));
        }
 public void CannotFlushAfterCancel()
 {
     using (var conv = new ScopedConversation(ConversationFlushMode.Explicit))
     {
         conv.Cancel();
         Assert.Throws<ActiveRecordException>(() => { conv.Flush(); });
     }
 }
Пример #3
0
 public void CannotFlushAfterCancel()
 {
     using (var conv = new ScopedConversation(ConversationFlushMode.Explicit))
     {
         conv.Cancel();
         Assert.Throws <ActiveRecordException>(() => { conv.Flush(); });
     }
 }
		public void CanSetFlushModeToNever()
		{
			ArrangeRecords();

			using (var conversation = new ScopedConversation(ConversationFlushMode.Explicit))
			{
				BlogLazy blog;
				using (new ConversationalScope(conversation))
				{
					blog = BlogLazy.FindAll().First();
					blog.Author = "Anonymous";
					blog.Save();
					BlogLazy.FindAll(); // Triggers flushing if allowed
				}

				Assert.That(blog.Author, Is.EqualTo("Anonymous"));

				// Outside any ConversationalScope session-per-request is used
				Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Markus"));

				conversation.Flush();
			}

			Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Anonymous"));
		}