PageRenderTime 66ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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

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