using System.Threading; using WatiN.Core; using MbUnit.Framework; namespace Site.Tests { [TestFixture(ApartmentState = ApartmentState.STA)] public class BaseTests { } }
[Test] public void CheckLoginPageRedirectsToHomePage() { IE ie = new IE(@"http://localhost/Authentication.aspx"); ie.TextField("ctl00_cphContenu_Login1_UserName").TypeText("testuser"); ie.TextField("ctl00_cphContenu_Login1_Password").TypeText("testpass"); ie.Button("ctl00_cphContenu_Login1_LoginButton").Click(); Assert.AreEqual(@"http://localhost/", ie.Url); ie.Close(); }
"1 passed, 0 failed, 0 skipped, took 10,96 seconds."
[TestFixture(ApartmentState = ApartmentState.STA)] public class BaseTests { private string membersFile; [TestFixtureSetUp] public void SetupTestFiles() { string thisPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string basePath = Path.Combine(thisPath, @"..SiteApp_Data"); membersFile = Path.Combine(basePath, "members.xml"); if(File.Exists(membersFile)) File.Move(membersFile, membersFile+".bak"); File.Copy(Path.Combine(thisPath, "members.xml"), membersFile); } [TestFixtureTearDown] public void CleanupTestFiles() { if (File.Exists(membersFile + ".bak")) { if(File.Exists(membersFile)) File.Delete(membersFile); File.Move(membersFile, membersFile + ".bak"); } } [RowTest] [Row(@"http://localhost/default.aspx")] [Row(@"http://localhost/prestations.html")] [Row(@"http://localhost/contact.aspx")] public void TestLoginFromAnyPage(string firstPage) { using(IE ie = new IE(firstPage)) { ie.Link(Find.ByText("Accès collaborateurs")).Click(); Assert.IsTrue(ie.Url.StartsWith("http://localhost/Authentication.aspx")); ie.TextField(Find.ById(new Regex(@"(w_)+UserName"))).TypeText("testuser"); ie.TextField(Find.ById(new Regex(@"(w_)+Password"))).TypeText("testpass"); ie.Button(Find.ById(new Regex(@"(w_)+LoginButton"))).Click(); Assert.AreEqual(firstPage, ie.Url); ie.Link(Find.ByText("Déconnexion")).Click(); Assert.AreEqual("Accès collaborateurs", ie.Div(Find.ById("acces")).Links[0].Text); } } [Test] public void CheckLoginPageRedirectsToHomePage() { IE ie = new IE("http://localhost/Authentication.aspx"); ie.TextField("ctl00_cphContenu_Login1_UserName").TypeText("testuser"); ie.TextField("ctl00_cphContenu_Login1_Password").TypeText("testpass"); ie.Button("ctl00_cphContenu_Login1_LoginButton").Click(); Assert.AreEqual("http://localhost/", ie.Url); ie.Close(); } }
Avis de décès, Carte de voeux, Bricolage, Coloriages, Cinéma, Coiffure, Cuisine, Déco, Dictionnaire, Horoscope, Jeux en ligne, Programme TV, Recettes, Restaurant, SMIC, Test débit, Voyage, Signification prénom