Telerik blogs
  • Productivity Testing

    Mocking Constructors with JustMock

    In .NET there are two types of constructors, instance constructors and static constructors. Instance constructors are called when objects are instantiated, while static constructors get called before any member of the class is invoked for the first time.
    December 13, 2012
  • Productivity

    Slides, Source Code and Video to the “Getting Started with JustMock” Webinar Now Available

    Chris and I wanted to thank you all for attending the “Getting Started with JustMock” webinar. The slides, source code and recorded video are now available for you to explore. If you have any questions, then feel free to leave a comment below or send us an email/tweet. I encourage you to go ahead and download your own copy of JustMock and start experiencing Fast, Fluid Unit Testing for yourself. WEBINAR MATERIALS Slides, Source Code and the Recorded Webinar Video is now available for you to enjoy.
    December 07, 2012
  • Productivity

    Future Mocking

    Mocking legacy code is hard. Especially, if it’s a third-party library and you have little control over how it’s written. It is even more difficult to unit test a type that is instantiated internally. One can argue that it should be refactored to accept dependencies via constructor injection.  However, constraints such as time, budget, experience with the offending code, or even access to the source often prevent paying down the technical debt accumulated in these legacy systems.   This post will show you how to mock an external library (concept) where it calls a login service class that cannot be sent...
    November 21, 2012
  • Productivity Testing

    Automocking with JustMock

    Auto mocking containers are designed to reduce the friction of keeping unit test beds in sync with the code being tested as systems are updated and evolve over time. Background The Dependency Inversion Principle states: High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions. As more developers follow this and the rest of Robert Martin’s SOLID principles, methods and classes become much smaller with dependent objects injected into them, typically through constructor injection. As additional dependencies are needed (or the code is refactored to improve dependency isolation), the signatures of...
    November 07, 2012
  • Productivity

    Mocking LINQ Queries

    Unit testing LINQ queries can be really challenging. This requires a deep knowledge of how LINQ queries work and how they filter results based on predicate values.  While I am adopting test first development approach, it is most likely that I want to verify the behavior of a query for correctness. In this post, I will show how easy it is to mock a LINQ query using JustMock for a given context. First, let me build up the context with a simple entity class for Employee that has two properties: Next, I created a dummy context that inherits the LINQ to SQL...
    November 02, 2012