Blog Posts for: Nbuilder

Unit Testing with NBuilder and NSubstitute using either a FakeDBSet or a mock DbSet

11 August 2015

In the previous blog post I showed how you can unit test with NBuilder and NSubstitute by using a FakeDbSet implementation. The thing is that we do not necessarily have to use a FakeDbSet but can also try and mock the DbSet. Let’s see how we can changes the implementation from last week’s blog post to mock DbSet instead. First thing to note is that a lot of examples for mocking the DbSet using other mocking frameworks such as Moq (such as this one) will demonstrate using DbSet and IQueryable, but it turns out that people using NSubstitute run into all sort of problems with this, as this SO question demonstrates.

Unit Testing with FakeDBSet and NBuilder

04 August 2015

Introduction I have mentioned in a previous blog post that I make use of NBuilder and Faker.NET to create test data for my application in development and testing scenarios. I also make use of NBuilder to set up scenarios for testing queries against my DbContext to ensure that the correct data is returned from a query. In this blog post I am going to demonstrate how you can test an ASP.

Create test data with NBuilder and Faker

07 July 2015

For many web applications you may want to generate some initial, semi-realistic test data for your development and testing environments. Entity Framework provides a handy mechanism through which you can achieve this, namely seed data. You can read Mike Wasson’s blog post on the ASP.NET website for some background on how to use create seed data with Entity Framework Code-First migrations. The Seed mechanism is handy for populating the database, but how do you create the actual test data?