Contents tagged with Unit Test

  • Assert the order of expected calls over instances

    How you assert through unit test that an user is authenticated before doing withdraw operation? You can surely verify a method is invoked as expected but if you want to ensure the order right then you might require a little more. JustMock lets you specify the order in which your setups should be executed. This helps you identify the exact way in which a particular logic is implemented.

  • Asserting a mock with test framework

    When asserting an expected call for its number of occurrences or may be just to verify if the setup/arrange is acted as intended, the tool generally raises assertion that points us to the reason why the test failed. Different mocking tools use different exception classes therefore there is no common way to consolidate them.

  • 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.

  • Hands on mocking of ASPNETMVC controller action

    In this post, i will start with an MVC sample created from the default template project that is bundled with ASPNET MVC2 installation. This template provides not just a dummy project with folder organized but rather a full running app.The target of this post is to show a mocking of a controller action, in that regard i have picked  registration action chosen from the accounts controller of the provided sample that looks similar to:

  • Adding custom interfaces to your mock instance.

    Previously, i made a post  showing how you can leverage the dependent interfaces that is implemented by JustMock during the creation of mock instance. It could be a informative post that let you understand how JustMock behaves internally for classes or interfaces implement other interfaces into it. But the question remains, how you can add your own custom interface to your target mock. In this post, i am going to show you just that.

  • Is your test method self-validating ?

    Writing state of art unit tests that can validate your every part of the framework is challenging and interesting at the same time, its like becoming a samurai. One of the key concept in this is to keep our test synced all the time as underlying code changes and thus breaking them to the furthest unit as possible.  This also means, we should avoid  multiple conditions embedded in a single test.