One of the biggest hurdles in writing tests for legacy code are future dependencies. They are called “future” objects, because they are created inside the class under test, rather then injected into it by the test. Let’s look at our Person constructor: Person::Person() { address = new Address(); } That address, right there, is …
Tag Archive: AAA
Permanent link to this article: http://www.typemock.com/blog/2010/10/20/how-to-setting-behavior-for-future-objects-with-isolator/
Aug
26
Debugging the Undebuggable
I bumped up against an interesting problem today. I was trying to write a unit test for our CRM code (I’ll write about my endeavor in a another post). Anyway, I was trying to test a method (a WebMethod, actually) that was inside a class, which was inside an asmx file. Strangely enough, I never …
Permanent link to this article: http://www.typemock.com/blog/2010/08/26/debugging-the-undebuggable/
Aug
11
How to fake C++ objects with Isolator++ (Beta)
It seems like everything in the C++ world is harder – you have two files per class, no garbage collection and you need to know your pointer tricks to get things done. It would have been only natural that unit tests would flourish in such a world that a project could live or die by …
Permanent link to this article: http://www.typemock.com/blog/2010/08/11/how-to-fake-c-objects-with-isolator-beta/
Aug
09
How to verify a method call on a dependency
Guest post by Lior Friedman. Interaction testing is a common type of unit testing. In this type of tests, one checks that a specific unit “interacts” with another way according to an agreed protocol, usually this protocol is embodied in the used class API. Its in interaction tests that mocking framework becomes real handy. Let’s …
Permanent link to this article: http://www.typemock.com/blog/2010/08/09/how-to-verify-a-method-call-on-a-dependency/
Jun
18
How to fake method’s parameters
Although Typemock Isolator know how to fake out and ref parameters there are times that a certain parameter passed to shall return a specific value. Consider this scenario – a call to a stream object: In the test we want to fake the return value but we also want to fill the byte array with …
Permanent link to this article: http://www.typemock.com/blog/2009/06/18/how-to-fake-method%e2%80%99s-parameters/
Jun
11
WCF Tip – How to unit test an ErrorProvider
A while ago this problem was brought to my attention by one of our customers: WCF enable us to add a custom error handler as part of the service implementation: The implementation of ErrorHandler is pretty straight forward: Writing a unit test for the error handling code seems easy (using Isolator) just call Fault and …
Permanent link to this article: http://www.typemock.com/blog/2009/06/11/wcf-tip-how-to-unit-test-an-errorprovider/
May
07
Quick tip – How to fake a singleton
The singleton pattern is well known and used in many software projects. Faking Singleton can be done by replacing the singleton class on creation or by faking the property (or method) that returns the singleton. Fake the next instance of the class – by using Swap.NextInstance to replace the next object instantiation with our fake …
Permanent link to this article: http://www.typemock.com/blog/2009/05/07/quick-tip-how-to-fake-a-singleton/
Apr
30
Faking WCF Async Calls – Part II
In the last post, I simulated an asynchronous call to WCF, by setting custom code behavior on the Begin and End. But that’s not enough. I want to make that even shorter and readable. And even ready for more generic use. I’m taking advantage of the fact that for a specific synchronous call in WCF, …
Permanent link to this article: http://www.typemock.com/blog/2009/04/30/faking-wcf-async-calls-part-ii/
Apr
30
Faking Async Calls in WCF – Part I
Once upon a time, I wrote about writing tests for WCF servers and clients. WCF can be invoked also in an async method. What you would do is generate WCF proxies that have method definition for your service starting with “Begin…” and “End…”, following the asynchronous method calling convention. As you may recall from our …
Permanent link to this article: http://www.typemock.com/blog/2009/04/30/faking-async-calls-in-wcf-part-i/
Apr
23
WCF tip – How to fake a method inside WebOperationContext
One of our customers had a very interesting problem. When using he needed to set WCF’s WebOperationContext.Current.IncomingRequest.UserAgent to return a specific string. Usually this would not have been a problem using the AAA API:
Permanent link to this article: http://www.typemock.com/blog/2009/04/23/wcf-tip-how-to-fake-a-method-inside-weboperationcontext/
