PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/BlogEngine/BlogEngine.Tests/Posts/Post.cs

#
C# | 61 lines | 45 code | 14 blank | 2 comment | 0 complexity | 92be93b29417e96c5a720a59648277cc MD5 | raw file
 1using NUnit.Framework;
 2using WatiN.Core;
 3using BlogEngine.Tests.PageTemplates.Admin;
 4
 5namespace BlogEngine.Tests.Posts
 6{
 7    [TestFixture]
 8    public class Post : BeTest
 9    {
10        string PostId = "";
11        string TheTestPost = "The test post";
12
13        [SetUp]
14        public void Init()
15        {
16            Login("admin");
17        }
18
19        [TearDown]
20        public void Dispose()
21        {
22            var trash = ie.Page<Trash>();
23            ie.GoTo(trash.Url);
24            trash.PurgeAll.Click();
25        }
26
27        [Test]
28        public void CanCreateAndDeletePost()
29        {
30            var editPost = ie.Page<EditPost>();
31
32            ie.GoTo(editPost.Url);
33
34            TypeQuickly(editPost.PostTitle, TheTestPost);
35            
36            ie.Eval(editPost.JsHack);
37
38            editPost.Save.Click();
39
40            SetPostId();
41
42            Assert.IsTrue(ie.ContainsText(TheTestPost));
43
44            ie.GoTo(ie.Page<PostList>().Url);
45            ie.Link(Find.ById("a-" + PostId)).Click();
46
47            // give 5 seconds for ajax method to execute
48            // and romove element from the page
49            Wait(5);
50
51            Assert.IsFalse(ie.ContainsText(TheTestPost));
52        }
53
54        void SetPostId()
55        {
56            var pos = ie.Html.IndexOf("deletepost=");
57            PostId = ie.Html.Substring(pos + 11, 36);
58            System.Console.WriteLine("Post ID is: " + PostId);
59        }
60    }
61}