Telerik blogs
  • 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 2 min read
  • Productivity

    Abstracting Dependencies with JustMock

    Unit tests are most effective when the System Under Test is isolated from its dependencies.  The best way to isolate your code (and make your code more SOLID) is through dependency injection. But even if you follow the rules of SOLID and inject all of the necessary dependencies in as interfaces, you are still faced with the fact that you depend on them. In order to test your code, something concrete has to be passed into the code in order for it to even compile.  Your production code will most likely use a factory to create concrete instances of the dependent interfaces, but that...
    October 31, 2012 4 min read
  • Productivity Testing

    Getting Started with NUnit, NUnit.Should, and JustMock

    Technorati Tags: TDD,Test Driven Development,JustMock,JustCode,NUnit,NUnit.Should,Mocking Before diving into mocking with JustMock, it’s important to note that JustMock is a mocking framework, and not a testing framework.  Test frameworks allow for creating Test Fixtures, which are .NET classes decorated with the appropriate attributes so they are picked up by a Test Runner.  Test are created within a Test Fixture by writing methods (with the appropriate attributes) that exercise your code (also referred to as the System Under Test) and report the results.  Test Runners are programs that will run your tests.  There are many free testing frameworks available for .NET developers, including MSTest (included...
    October 05, 2012 12 min read
  • Productivity

    Why I Hate Unit Testing

    So you went to work for the cool company that wooed you with promises of cutting edge technologies and techniques. In the interview, they told you that they are agile and unit test everything. You may or may not have been in an agile environment before, but the important thing you are enthusiastic about joining a team that truly gets software development. You tested on your previous job, even using JustMock to write better tests. You promise you can be agile yourself and quickly adopt their practices. You’re immediately hired. Many of you have been there… maybe you’re there right now. It takes...
    May 17, 2012 5 min read
  • Productivity

    Mocking the File System to Improve Testability (with JustMock)

    Many applications require access to the file system to create, modify or delete files and folders. But how do you make sure that such application behaves correctly? You do it with tests of course but there is a catch: In general it is not a good idea to have tests that are performing Input/Output operations like accessing files and databases. When you need to test I/O operations mock objects are your friend. And before I go into more details let me point out some of the benefits of mocking. Usually faster than performing I/O operations You do not have have to deal...
    June 10, 2010 5 min read