コード例 #1
0
 public void CannotFlushAfterCancel()
 {
     using (var conv = new ScopedConversation(ConversationFlushMode.Explicit))
     {
         conv.Cancel();
         Assert.Throws<ActiveRecordException>(() => { conv.Flush(); });
     }
 }
コード例 #2
0
 public void CannotFlushAfterCancel()
 {
     using (var conv = new ScopedConversation(ConversationFlushMode.Explicit))
     {
         conv.Cancel();
         Assert.Throws <ActiveRecordException>(() => { conv.Flush(); });
     }
 }
コード例 #3
0
 public void CanCheckWhetherAConversationWasCanceled()
 {
     using (var c = new ScopedConversation())
     {
         Assert.That(c.IsCanceled, Is.False);
         c.Cancel();
         Assert.That(c.IsCanceled);
     }
 }
コード例 #4
0
 public void CanCheckWhetherAConversationWasCanceled()
 {
     using (var c = new ScopedConversation())
     {
         Assert.That(c.IsCanceled, Is.False);
         c.Cancel();
         Assert.That(c.IsCanceled);
     }
 }
コード例 #5
0
 public void CanRestartAConversation()
 {
     using (var c = new ScopedConversation())
     {
         Assert.That(c.IsCanceled, Is.False);
         c.Cancel();
         Assert.That(c.IsCanceled);
         c.Restart();
         Assert.That(c.IsCanceled, Is.False);
     }
 }
コード例 #6
0
 public void CanRestartAConversation()
 {
     using (var c = new ScopedConversation())
     {
         Assert.That(c.IsCanceled, Is.False);
         c.Cancel();
         Assert.That(c.IsCanceled);
         c.Restart();
         Assert.That(c.IsCanceled, Is.False);
     }
 }
コード例 #7
0
        public void TriggersEventWhenCanceling()
        {
            bool triggered = false;

            using (var c = new ScopedConversation())
            {
                c.Canceled += (conv, args) => triggered = true;
                c.Cancel();
            }

            Assert.That(triggered);
        }
コード例 #8
0
        public void TriggersWithRightArgsWhenCanceling()
        {
            bool triggered  = false;
            bool userCancel = false;

            using (var c = new ScopedConversation())
            {
                c.Canceled += (conv, args) => { triggered  = true;
                                                userCancel = args.CanceledByUser; };
                c.Cancel();
            }

            Assert.That(triggered);
            Assert.That(userCancel);
        }
コード例 #9
0
        public void ThrowsReasonableErrorMessageWhenUsedAfterCancel()
        {
            using (var conversation = new ScopedConversation())
            {
                conversation.Cancel();

                var ex = Assert.Throws <ActiveRecordException>(() =>
                {
                    using (new ConversationalScope(conversation))
                        BlogLazy.FindAll();
                }
                                                               );

                Assert.That(ex.Message.Contains("cancel"));
                Assert.That(ex.Message.Contains("ConversationalScope"));
                Assert.That(ex.Message.Contains("session"));
                Assert.That(ex.Message.Contains("request"));
            }
        }
コード例 #10
0
		public void CanCancelConversations()
		{
			ArrangeRecords();
    		using (var conversation = new ScopedConversation())
    		{
    			BlogLazy blog = null;
    			using (new ConversationalScope(conversation))
    			{
    				blog = BlogLazy.FindAll().First();
    			}

    			blog.Author = "Somebody else";

    			using (new ConversationalScope(conversation))
    			{
    				blog.SaveAndFlush();
    			}

    			conversation.Cancel();
    		}
			Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Markus"));
		}
コード例 #11
0
        public void CanCancelConversations()
        {
            ArrangeRecords();
            using (var conversation = new ScopedConversation())
            {
                BlogLazy blog = null;
                using (new ConversationalScope(conversation))
                {
                    blog = BlogLazy.FindAll().First();
                }

                blog.Author = "Somebody else";

                using (new ConversationalScope(conversation))
                {
                    blog.SaveAndFlush();
                }

                conversation.Cancel();
            }
            Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Markus"));
        }
コード例 #12
0
        public void TriggersWithRightArgsWhenCanceling()
        {
            bool triggered = false;
            bool userCancel = false;
            using (var c = new ScopedConversation())
            {
                c.Canceled += (conv, args) => { triggered = true;
                                              	userCancel = args.CanceledByUser; };
                c.Cancel();
            }

            Assert.That(triggered);
            Assert.That(userCancel);
        }
コード例 #13
0
        public void TriggersEventWhenCanceling()
        {
            bool triggered = false;
            using (var c = new ScopedConversation())
            {
                c.Canceled += (conv,args) => triggered = true;
                c.Cancel();
            }

            Assert.That(triggered);
        }
コード例 #14
0
        public void ThrowsReasonableErrorMessageWhenUsedAfterCancel()
        {
            using (var conversation = new ScopedConversation())
            {
                conversation.Cancel();

                var ex = Assert.Throws<ActiveRecordException>(() =>
                                                              	{
                                                              		using (new ConversationalScope(conversation))
                                                              			BlogLazy.FindAll();
                                                              	}
                    );

                Assert.That(ex.Message.Contains("cancel"));
                Assert.That(ex.Message.Contains("ConversationalScope"));
                Assert.That(ex.Message.Contains("session"));
                Assert.That(ex.Message.Contains("request"));
            }
        }