Пример #1
0
 public void ConversationIsCanceledAfterErrorInExecute()
 {
     using (var c = new ScopedConversation())
     {
         Assert.Throws <ApplicationException>(() => c.Execute(() => new PostLazy().SaveWithException()));
         Assert.That(c.IsCanceled);
     }
 }
        public void CanUseIConversationDirectly()
        {
            ArrangeRecords();

            using (IConversation conversation = new ScopedConversation())
            {
                BlogLazy blog = null;
                conversation.Execute(() => { blog = BlogLazy.FindAll().First(); });

                Assert.That(blog, Is.Not.Null);
                Assume.That(blog.Author, Is.EqualTo("Markus"));

                // Lazy access
                Assert.That(blog.PublishedPosts.Count, Is.EqualTo(1));

                blog.Author = "Anonymous";

                conversation.Execute(() => blog.Save());
            }

            Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Anonymous"));
        }
    	public void CanUseIConversationDirectly()
    	{
    		ArrangeRecords();

    		using (IConversation conversation = new ScopedConversation())
    		{
    			BlogLazy blog = null;
    			conversation.Execute(() => { blog = BlogLazy.FindAll().First(); });

				Assert.That(blog, Is.Not.Null);
				Assume.That(blog.Author, Is.EqualTo("Markus"));

				// Lazy access
				Assert.That(blog.PublishedPosts.Count, Is.EqualTo(1));

    			blog.Author = "Anonymous";

    			conversation.Execute(() => blog.Save());
				
    		}

			Assert.That(BlogLazy.FindAll().First().Author, Is.EqualTo("Anonymous"));
    	}
 public void ConversationIsCanceledAfterErrorInExecute()
 {
     using (var c = new ScopedConversation())
     {
         Assert.Throws<ApplicationException>(() => c.Execute(() => new PostLazy().SaveWithException()));
         Assert.That(c.IsCanceled);
     }
 }