Mehfuz's WebLog
Live crazy, think different!
-
Running JustMock profiler outside of Visual Studio
In this post , I would be focusing on the issue that generally comes to query on how to run JustMock with standalone tools like nunit or msbuild console. Since mocking concrete method works initializing the .net profiler that is set using two variables in the runtime to let JustMock work the correct way.
-
Mocking MsCorlib members
In this post , I will show how you can mock members from MsCorlib. This is more of an introductory post and shows what you need to do in order to successfully mock an MsCorlib member.
-
Mocking constructor
While unit testing a target type, it is likely that the test is failing during object creation because we forgot to include a mandatory configuration file or a line in the constructor is throwing exception because it is making call to some external service or data store which on the other hand requires a little more orchestration to get things going . To better illustrate this, let’s create an entity framework data container either new or from an existing database. Once we have completed the required steps, there will be an entry-point class where we will notice the following default constructor:
-
NuGet JustMock
As most of us already know JustMock got a free edition. The free edition is not a stripped down of the features of the full edition but I would rather say its a strip down of the type you can mock. Technically, free version runs on proxy as full version runs on proxy + profiler. In full version, It switches to profiler when you are mocking final methods or sealed class or anything else that can not be done using inheritance. Like in full version you can mock non public methods , in free version you can still do it but it has to be virtual for protected or must be done through InternalsVisibleTo attribute for internal virtual methods (If you have access to the source and can apply the attribute).
-
Writing LINQ providers easily and elegantly (LinqExtender 3.0)
When writing a custom LINQ provider, developer must focus into plenty of issues other than the main purpose of just creating a LINQ to something. Like how to deal with projection, how to parse valued expressions, how to parse members, how to do orderby and the list goes on.
-
How to raise event for a mocked call.
Recently, while i was working with a support issue , i found this interesting piece of test code that i would like to share here. This is actually written by Stefan Lieser (clean code developer from Germany forwarded to me by Jan from Telerik Germany). As the title states, it is to mock a specific event for an expected call.
-
Mocking SPContext.Current with JustMock
Today, I happen to find an interesting post on mocking SharePoint context using TypeMock. Being a JustMocker, i thought rather to follow the footsteps and see if can do the same with JustMock. I am no SharePoint expert. Occasionally, I use a Windows 2003 VM with SharePoint server installed which gives me the required flavor of SharePoint for testing SP capabilities of JM.
-
Back to school : Getting to know F#
This post starts with a basic introduction of F# and finally ends up writing a simple unit test for an F# member. For those who don’t know what F# is all about, Its a product from Microsoft research and now part of VS 2010 family. Actually from Wikipedia it is described as follows:
-
Mocking LINQ to SQL (Continued…) using OpenAccess
After making the post on mocking LINQ to SQL, this morning i was having a chat with Stephen forte and come to know that Telerik has a new product named Visual Entity Designer that enables you to define your domain model very easily through just few clicks and builds a nice LINQ to SQL model that mimics model similar to Entity framework / MS LINQ to SQL. Being curious, i thought of giving a spin with it and try to mock OpenAccess LINQ to SQL implementation using JustMock.
-
Unit testing LINQ to SQL
Unit testing LINQ to SQL repositories can be very challenging. Unit testing such requires faking hard to mock classes and requires simulation to return your custom data for a particular LINQ statement. In this post, i will show how you can mock your LINQ repositories easily without much digging in.