/BlogEngine/BlogEngine.Tests/BeTest.cs
C# | 78 lines | 58 code | 18 blank | 2 comment | 5 complexity | a78a0998d9a09e40b8cd174c3459d3a2 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
- using System;
- using NUnit.Framework;
- using WatiN.Core;
- using BlogEngine.Tests.PageTemplates.Account;
-
- namespace BlogEngine.Tests
- {
- public abstract class BeTest
- {
- protected IE ie = null;
-
- [TestFixtureSetUp]
- public void SetUp()
- {
- ie = new IE();
-
- ie.Refresh();
- ie.ClearCache();
-
- Settings.WaitForCompleteTimeOut = 240;
-
- // to hide IE window
- // ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Hide);
- }
-
- [STAThread]
- static void Main(string[] args)
- {
-
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- ie.Close();
- }
-
- public void Login(string user, string pwd = "")
- {
- if (string.IsNullOrEmpty(pwd))
- pwd = user;
-
- var login = ie.Page<Login>();
-
- ie.GoTo(login.Url);
-
- TypeQuickly(login.UserName, user);
- TypeQuickly(login.Password, pwd);
-
- login.LoginButton.Click();
- }
-
- public void Logout()
- {
- ie.GoTo(Constants.Root);
-
- var login = ie.Page<Login>();
- var logOffLink = login.LogoffLink;
-
- if (logOffLink != null && logOffLink.Text == Constants.LogOff)
- {
- logOffLink.Click();
- }
- }
-
- public static void TypeQuickly(TextField textField, string text)
- {
- textField.SetAttributeValue("value", text);
- }
-
- public void Wait(int seconds)
- {
- int i;
- int.TryParse(string.Format("{0}000", seconds), out i);
- System.Threading.Thread.Sleep(i);
- }
- }
- }