[Fat-develop] FAT/src/FAT.Core ITestFixtureHtmlFormatter.cs,NONE,1.1 TestFixtureHtmlFormatter.cs,NON
Brought to you by:
exortech
|
From: <dmc...@us...> - 2004-02-20 20:44:19
|
Update of /cvsroot/fat/FAT/src/FAT.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3930/src/FAT.Core Modified Files: FAT.Core.csproj TestFixtureLoader.cs Added Files: ITestFixtureHtmlFormatter.cs TestFixtureHtmlFormatter.cs Log Message: Can now click on question mark gif next to selected fixture name to get a pop-up window giving help on available methods. --- NEW FILE: ITestFixtureHtmlFormatter.cs --- using System; using System.Web.UI; namespace FAT.Core { public interface ITestFixtureHtmlFormatter { Control Format(Type type, string fixture); } } --- NEW FILE: TestFixtureHtmlFormatter.cs --- using System; using System.Collections; using System.IO; using System.Reflection; using System.Text.RegularExpressions; using System.Text; using System.Web.UI; using System.Web.UI.WebControls; namespace FAT.Core { public class TestFixtureHtmlFormatter : ITestFixtureHtmlFormatter { public Control Format(Type type, string fixture) { Table table = new Table(); table.CellSpacing = 8; table.Rows.Add(CreateHeaderRow(fixture)); foreach (MethodInfo methodInfo in GetMethodInfos(type)) { table.Rows.Add(CreateMethodRow(methodInfo)); } table.Rows.Add(CreateImplementingClassRow(type.FullName)); return table; } private TableRow CreateHeaderRow(string fixture) { TableRow row = new TableRow(); TableCell cell = CreateCell("Methods on Fixture " + fixture, 2); row.Cells.Add(cell); return row; } private TableRow CreateMethodRow(MethodInfo methodInfo) { TableRow row = new TableRow(); row.Cells.Add(CreateCell(ConvertToFATMethodName(methodInfo))); row.Cells.Add(CreateCell(GetFormattedParameterNames(methodInfo.GetParameters()))); return row; } private TableRow CreateImplementingClassRow(string typeName) { TableRow row = new TableRow(); TableCell cell = CreateCell("Implementing Class is " + typeName, 2); row.Cells.Add(cell); return row; } private TableCell CreateCell(string content) { return CreateCell(content, 1); } private TableCell CreateCell(string content, int colSpan) { TableCell cell = new TableCell(); cell.ColumnSpan = colSpan; cell.Text = content == string.Empty ? " " : content; return cell; } private MethodInfo []GetMethodInfos(Type type) { ArrayList methodInfos = new ArrayList(); foreach (Type currentType in GetAllTypesInInheritanceHeirarchy(type)) { foreach (MethodInfo methodInfo in currentType.GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly)) { methodInfos.Add(methodInfo); } } return (MethodInfo [])methodInfos.ToArray(typeof(MethodInfo)); } private Type []GetAllTypesInInheritanceHeirarchy(Type type) { ArrayList baseClassTypes = new ArrayList(); for (Type currentType = type; currentType != typeof(object); currentType = currentType.BaseType) { baseClassTypes.Add(currentType); } return (Type [])baseClassTypes.ToArray(typeof(Type)); } private string ConvertToFATMethodName(MethodInfo methodInfo) { string methodName = methodInfo.Name; return methodName.Substring(0, 1) + Regex.Replace(methodName.Substring(1), "([A-Z])", " $1").ToLower().Trim() + ((methodInfo.GetParameters().Length > 0) ? ":" : ""); } private string GetFormattedParameterNames(ParameterInfo []parameterInfos) { return String.Join(" ", GetMethodParameterNamesAsStringArray(parameterInfos)); } private string []GetMethodParameterNamesAsStringArray(ParameterInfo []parameterInfos) { string []names = new string[parameterInfos.Length]; for (int n = 0; n < parameterInfos.Length; n++) { names[n] = parameterInfos[n].Name; } return names; } } } Index: FAT.Core.csproj =================================================================== RCS file: /cvsroot/fat/FAT/src/FAT.Core/FAT.Core.csproj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FAT.Core.csproj 8 Feb 2004 16:53:23 -0000 1.4 --- FAT.Core.csproj 20 Feb 2004 17:56:50 -0000 1.5 *************** *** 73,76 **** --- 73,81 ---- HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll" /> + <Reference + Name = "System.Web" + AssemblyName = "System.Web" + HintPath = "..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Web.dll" + /> </References> </Build> *************** *** 128,131 **** --- 133,141 ---- /> <File + RelPath = "ITestFixtureHtmlFormatter.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "ITestFixtureLoader.cs" SubType = "Code" *************** *** 203,207 **** /> <File ! RelPath = "TestFixtureDescription.cs" SubType = "Code" BuildAction = "Compile" --- 213,217 ---- /> <File ! RelPath = "TestFixtureHtmlFormatter.cs" SubType = "Code" BuildAction = "Compile" Index: TestFixtureLoader.cs =================================================================== RCS file: /cvsroot/fat/FAT/src/FAT.Core/TestFixtureLoader.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestFixtureLoader.cs 8 Feb 2004 16:53:23 -0000 1.4 --- TestFixtureLoader.cs 20 Feb 2004 17:56:50 -0000 1.5 *************** *** 23,34 **** public ITestFixture GetFixture(string fixture) { ! GetFixtureVisitor getFixtureVisitor = new GetFixtureVisitor(fixture); ! VisitFixtures(getFixtureVisitor); ! return getFixtureVisitor.Fixture; } public Type GetType(string fixture) { ! return typeof(TestFileScanner); } --- 23,34 ---- public ITestFixture GetFixture(string fixture) { ! return new TestFixture(fixture, new TestStepInvoker(GetType(fixture))); } public Type GetType(string fixture) { ! FixtureTypeFinderVisitor fixtureTypeFinderVisitor = new FixtureTypeFinderVisitor(fixture); ! VisitFixtures(fixtureTypeFinderVisitor); ! return fixtureTypeFinderVisitor.FixtureType; } *************** *** 70,79 **** } ! class GetFixtureVisitor : IFixtureVisitor { private string fixtureNameToFind; ! private TestFixture fixture = null; ! public GetFixtureVisitor(string fixtureNameTofind) { this.fixtureNameToFind = fixtureNameTofind; --- 70,79 ---- } ! class FixtureTypeFinderVisitor : IFixtureVisitor { private string fixtureNameToFind; ! private Type fixtureType = null; ! public FixtureTypeFinderVisitor(string fixtureNameTofind) { this.fixtureNameToFind = fixtureNameTofind; *************** *** 82,95 **** public void VisitFixture(string fixtureName, Type type) { ! if (fixtureName == fixtureNameToFind) fixture = new TestFixture(fixtureName, new TestStepInvoker(type)); } ! public TestFixture Fixture { ! get { ! if (fixture == null) ! { ! throw new TestFixtureLoadException(fixtureNameToFind); ! } ! return fixture; } } --- 82,93 ---- public void VisitFixture(string fixtureName, Type type) { ! if (fixtureName.Equals(fixtureNameToFind)) fixtureType = type; } ! public Type FixtureType { ! get ! { ! if (fixtureType == null) throw new TestFixtureLoadException(fixtureNameToFind); ! return fixtureType; } } |