Generic Method Helpers
Per request of Paulo Morgado and others, we are implementing Generic API’s for TypeMock.
TypeMock has supported Generic since .NET 2.0 Beta has been out, but it did not use Generics in the API’s.
This is mainly to allow developers to use the same API’s for all .NET versions and to be able to upgrade their applications .NET version without problems.
We will add a new assembly with the Generic API’s. Here is what we are thinking of implementing:
// Create a Mock Mock m = Mock<TestedClass>.MockNextInstance(); // Mock all instances of a Type Mock m = Mock<TestedClass>.MockAll(); // Create a mocked instance MockObject<TestedClass> m = MockObject<TestedClass>.Create(); TestedClass t = m.Object; // Create a mocked instance for NaturalMocks TestedClass t = MockObject<TestedClass>.CreateObject();
Here are the API’s for generic Methods
// mock with Generic Method Mock m = Mock<GenMethodClass>.MockNextInstance(); m.AlwaysReturn("GenMethod", 11, Generic.Method<int>()); // run it GenMethodClass t = new GenMethodClass(); Assert.AreEqual(11, t.GenMethod<int>(1))
We will also be able to verify parameter types with
mock.ExpectCall("PassObject").Args(Check<IList>);
Any ideas from the community will be appreciated
Recent Posts
- Unacceptable: Unit testing will take 20 years to catch on
- The 4 reasons why we DIDN’T choose Oslo
- Typemock Academy Launch
- The First Rule to Software Craftsmanship
- Goal-driven Development
Categories
- .NET Tests
- Agile
- Code Integrity
- Community
- Debugging
- Fun
- Management for Geeks
- Marketing
- Product
- Release
- Reviews
- SharePoint
- TDD
- Time Management
- Uncategorized
- Unit Tests
Archives
- May 2010
- April 2010
- March 2010
- February 2010
- December 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- December 2008
- November 2008
- August 2008
- July 2008
- May 2008
- April 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
