From: Griffin C. <gc...@us...> - 2005-04-23 21:28:47
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23363/DotNetMock.Tests/Dynamic Added Files: MethodSignatureTests.cs Log Message: - Added Romans' MethodSignature abstraction --- NEW FILE: MethodSignatureTests.cs --- using System; using System.Reflection; using DotNetMock.Dynamic; using NUnit.Framework; namespace DotNetMock.Tests.Dynamic { [TestFixture] public class MethodSignatureTest { #region Test Cases /// <summary> /// Test Equals method. /// </summary> [Test] public void TestEquals( ) { MethodSignature sign1 = new MethodSignature( "Method1", typeof ( Exception ), typeof ( bool ), typeof ( object ), typeof ( Exception ) ); MethodSignature sign2 = new MethodSignature( "Method1", typeof ( Exception ), typeof ( bool ), typeof ( object ), typeof ( Exception ) ); MethodSignature sign3 = new MethodSignature( "Method2", typeof ( Exception ), typeof ( bool ), typeof ( object ), typeof ( Exception ) ); MethodSignature sign4 = new MethodSignature( "Method1", typeof ( void ), typeof ( bool ), typeof ( object ), typeof ( Exception ) ); MethodSignature sign5 = new MethodSignature( "Method1", typeof ( Exception ), typeof ( object ), typeof ( Exception ) ); Assert.IsTrue( sign1.Equals( sign2 ), "sign1.Equals(sign2) shall be true." ); Assert.IsFalse( sign1.Equals( sign3 ), "sign1.Equals(sign3) shall be false." ); Assert.IsFalse( sign1.Equals( sign4 ), "sign1.Equals(sign4) shall be false." ); Assert.IsFalse( sign1.Equals( sign5 ), "sign1.Equals(sign5) shall be false." ); } /// <summary> /// New instance of signature can be created from MethodInfo type parameter. /// </summary> [Test] public void ConstructorWithMethodInfoParameter( ) { MethodInfo methodInfo = typeof ( MethodSignatureTest ).GetMethod( "TestMethod" ); MethodSignature signature1 = new MethodSignature( methodInfo ); MethodSignature signature2 = new MethodSignature( "TestMethod", typeof ( int ), typeof ( object ), typeof ( int ) ); Assert.AreEqual( signature1, signature2, "signature1 shall be equal to signature2." ); } /// <summary> /// Test ToString() routine. /// </summary> [Test] public void TestToString( ) { MethodSignature sign = new MethodSignature( "Method1", typeof ( Exception ), typeof ( bool ), typeof ( object ), typeof ( Exception ) ); string actual = sign.ToString( ); string expected = "System.Exception Method1(System.Boolean, System.Object, System.Exception)"; Assert.AreEqual( expected, actual ); } #endregion /// <summary> /// Method used for testing. This method is not being called but simply here to supply MethodInfo /// structure for testing. /// </summary> public int TestMethod( object obj, int i ) { throw new InvalidOperationException( "This method is for testing purposes only and shall never be called." ); } } } |