From: Choy R. <ch...@us...> - 2005-01-25 06:21:03
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22568/DotNetMock Modified Files: Tag: RFE_1098585 Assertion.cs DotNetMock.csproj Log Message: Initial implementation of dynamically generating implementations of ITestFramework on startup. So far created impls for NUnit and MbUnit. Needs some cleanup. Index: Assertion.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Assertion.cs,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -C2 -d -r1.5 -r1.5.4.1 *** Assertion.cs 9 Oct 2004 21:14:12 -0000 1.5 --- Assertion.cs 25 Jan 2005 06:20:49 -0000 1.5.4.1 *************** *** 1,7 **** --- 1,9 ---- using System; using System.Configuration; + using System.IO; using System.Reflection; using System.Runtime.Remoting; using DotNetMock.Core; + using DotNetMock.TestFramework; namespace DotNetMock *************** *** 28,39 **** if ( ( iTestFrameworkAssembly == null ) || ( iTestFrameworkAssembly.Equals( String.Empty ) ) ) { ! iTestFrameworkAssembly = "DotNetMock.NUnit"; ! } ! if ( ( iTestFrameworkComponent == null ) || ( iTestFrameworkComponent.Equals( String.Empty ) ) ) { ! iTestFrameworkComponent = "DotNetMock.NUnit.NUnitTestFramework"; } - ObjectHandle concreteObject = Activator.CreateInstance( iTestFrameworkAssembly, iTestFrameworkComponent ); - _testFramework = (ITestFramework)concreteObject.Unwrap(); } /// <summary> --- 30,62 ---- if ( ( iTestFrameworkAssembly == null ) || ( iTestFrameworkAssembly.Equals( String.Empty ) ) ) { ! StubClassMaker classMaker = new StubClassMaker(); ! IStubMaker stubMaker = null; ! Assembly providerAssembly = null; ! if ( (providerAssembly = TryToLoadAssembly("nunit.framework"))!=null ) ! { ! stubMaker = new NUnitStubMaker(providerAssembly); ! } ! else if ( (providerAssembly = TryToLoadAssembly("MbUnit.Core"))!=null ) ! { ! stubMaker = new MbUnitStubMaker(providerAssembly); ! } ! if ( stubMaker==null ) ! { ! throw new InvalidOperationException( ! "Cannot find a testing framework" ! ); ! } ! Type stubClass = classMaker.MakeStubClass( ! typeof(ITestFramework), ! stubMaker ! ); ! _testFramework = (ITestFramework) ! Activator.CreateInstance(stubClass); ! } ! else { ! ObjectHandle concreteObject = Activator.CreateInstance( iTestFrameworkAssembly, iTestFrameworkComponent ); ! _testFramework = (ITestFramework)concreteObject.Unwrap(); } } /// <summary> *************** *** 179,182 **** --- 202,217 ---- } } + + private static Assembly TryToLoadAssembly(string assemblyName) + { + try + { + return Assembly.LoadWithPartialName(assemblyName); + } + catch (FileNotFoundException) + { + return null; + } + } } } Index: DotNetMock.csproj =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/DotNetMock.csproj,v retrieving revision 1.30 retrieving revision 1.30.2.1 diff -C2 -d -r1.30 -r1.30.2.1 *** DotNetMock.csproj 9 Jan 2005 06:48:35 -0000 1.30 --- DotNetMock.csproj 25 Jan 2005 06:20:49 -0000 1.30.2.1 *************** *** 40,44 **** RegisterForComInterop = "false" RemoveIntegerChecks = "false" ! TreatWarningsAsErrors = "true" WarningLevel = "4" /> --- 40,44 ---- RegisterForComInterop = "false" RemoveIntegerChecks = "false" ! TreatWarningsAsErrors = "false" WarningLevel = "4" /> *************** *** 349,352 **** --- 349,377 ---- BuildAction = "Compile" /> + <File + RelPath = "TestFramework\AbstractStubMaker.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TestFramework\IStubMaker.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TestFramework\MbUnitStubMaker.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TestFramework\NUnitStubMaker.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "TestFramework\StubClassBuilder.cs" + SubType = "Code" + BuildAction = "Compile" + /> </Include> </Files> |