using System;
using System.Collections.Generic;
using System.Text;
using Systin.Library;
using WatiN.Core;
using System.Threading;
using System.Reflection;
using System.IO;
namespace LanguageLibrary{
[LanguageDriver]
public class LanguageDriverTestClass
{
private Stack<string> mCallStack = new Stack<string>();
public Stack<string> CallStack
{
get { return mCallStack; }
}
[Systin]
public void Log_Into_system()
{
this.mCallStack.Push("Log_Into_system");
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
[Systin]
public void Log_Into_System_fully()
{
Set_User_Name();
Press_Login_Button();
Set_Password();
this.mCallStack.Push("Log_Into_System_fully");
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
[Systin]
public void Go_to_google()
{
IE ie = null;
try
{
// Open an new Internet Explorer Window and
// goto the google website.
ie = new IE("http://www.google.com");
// Find the search text field and type Watin in it.
ie.TextField(Find.ByName("q")).TypeText("WatiN");
// Click the Google search button.
ie.Button(Find.ByValue("Google Search")).Click();
}
finally
{
ie.Close();
}
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
[Systin]
public void Press_Login_Button()
{
this.mCallStack.Push("Press_Login_Button");
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
[Systin]
public void Set_User_Name()
{
this.mCallStack.Push("Set_User_Name");
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
[Systin]
public void Set_Password()
{
this.mCallStack.Push("Set_Password");
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
[Systin]
public void Click_Time_button()
{
this.mCallStack.Push("Click_Time_button");
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
public void Bad_Method_Not_Tagged()
{
this.mCallStack.Push("Bad_Method_Not_Tagged");
Log.Message(MethodInfo.GetCurrentMethod().Name);
}
[Systin]
public void Bad_Method_Programmed_Incorrectly()
{
String test = null;
//Throw an exception
try
{
test.Equals("something");
}
catch (Exception e)
{
Log.Message(MethodInfo.GetCurrentMethod().Name);
Log.Message(e.InnerException.ToString());
throw e;
}
}
}
public class BadLanguageDriverTestClass { }
internal class Log
{
private static string baseLineLogFile = "Baseline.log";
public static void Message(String message)
{
string currentDirectory = System.IO.Directory.GetCurrentDirectory();
string baseLineFile = Path.Combine(currentDirectory, baseLineLogFile);
if (!File.Exists(baseLineFile))
{
File.Create(baseLineFile);
}
try
{
File.AppendAllText(baseLineFile, message + "\r\n");
}
catch (Exception)
{
}
}
}
}
|