namespace ASPNetTestcase {

 

using System;

using System.IO;

using Microsoft.Web.Testing;

using Microsoft.Web.Testing.Components;

using Microsoft.Web.Testing.Management;

using Microsoft.Web.Testing.Context;

using Microsoft.Web.Testing.Context.Browsers;

 

public class WebPartsTestCase : Testcase {

 

public void Run() {

 

//-----------------------------------

//@ Deploy the files and request the page

//-----------------------------------

Scenario("Deploy the files and request the page", "Start");

 

// Create a Web.Config file and Deploy it

WebConfig config = new WebConfig("Web.Config");

 

// Turn off Custom Errors

config.SetConfigAttribute("system.web/customErrors", "mode", "Off");

Context.ActiveVirtualDirectory.Deploy(config, string.Empty);

Context.ActiveVirtualDirectory.Deploy(new string[] {"Login.aspx"},string.Empty);

Context.ActiveVirtualDirectory.Deploy(new string[] {"Test.Skin"}, AspNetFolders.Themes + "/Test");

 

// Create the Data Folder and add permissions to the ASP.NET Process Identity

string dataFolder = Path.Combine(Context.ActiveVirtualDirectory.PhysicalPath, AspNetFolders.Data);

Context.Server.Os.CreateDirectory(dataFolder);

Context.Server.Os.ChangeAcl(dataFolder, "/E /T /P \"" + Context.ActiveVirtualDirectory.GetProcessIdentity() + "\":F");

 

// Load the page and run it

Page page = new Page();

page.LoadFromFile("Page.aspx");

Client.ExecutePage(page);

 

//-----------------------------------

//@ Log In into the Web Site

//-----------------------------------

Scenario("Log In into the Web Site", "LogIn");

WebParts.LoginPage.LogIn("user_admin", "123");

Verifier.Verify();

 

//-----------------------------------

//@ Drag And Drop Calendar1 after the Button

//-----------------------------------

Scenario("Drag And Drop Calendar1 after the Button", "DragAndDrop");

IE60 ie = (IE60)Client.Browser;

WebParts.WebPart.DragAndDrop(ie, "gwpCalendar1", "gwpButton1", false);

Verifier.Verify();

 

//-----------------------------------

//@ Minimize Calendar2

//-----------------------------------

Scenario("Minimize Calendar2", "Minimize");

WebParts.WebPart.ClickMinimize(ie, "WebPart_gwpCalendar2");

Verifier.Verify();

 

//-----------------------------------

//@ Close the Button WebPart

//-----------------------------------

Scenario("Close the Button WebPart", "Close");

WebParts.WebPart.ClickClose(ie, "WebPart_gwpButton1");

Verifier.Verify();

 

//--------------------------------

//@ Click the 14th of the Month

//--------------------------------

Scenario("Click the 14th of the Month", "Click14th");

Client.Browser.ClickLink("14", 2, true);

Verifier.Verify();

 

//--------------------------------

//@ Click the 28th of the Month

//--------------------------------

Scenario("Click the 28th of the Month", "Click28th");

Client.Browser.ClickLink("28", 2, true);

Verifier.Verify();

}

}

}