NSubstitute vs Moq vs FakeItEasy vs Rhino

The long and short of this article is that I tried out a whole load of mocking frameworks and decided I liked NSubstitute the best. This is currently a reasonably simple decision, because on the whole, Moq, FakeItEasy, Rhino, JustMock and many others besides are all essentially syntactical best friends. There may be some minorContinue reading “NSubstitute vs Moq vs FakeItEasy vs Rhino”

Mocking Entity Framework DbContext and IDbSet With Rhino Mocks

This is something that can take a little figuring out – using Rhino Mocks to mock a DbContext and the associated IDBSets. Because of this, I created a little generic method that helps a lot… private static IDbSet<T> GetDbSetTestDouble<T>(IList<T> data) where T : class { IQueryable<T> queryable = data.AsQueryable(); IDbSet<T> dbSet = MockRepository.GenerateMock<IDbSet<T>, IQueryable>(); dbSet.Stub(mContinue reading “Mocking Entity Framework DbContext and IDbSet With Rhino Mocks”

Mocking a Service Proxy in .NET with Rhino Mocks

If you are calling a service via a service proxy, how do you mock the service call and ensure it was called with the correct parameters? Here is an example using Rhino Mocks to capture the call via the proxy and then test that it is the correct call. namespace Fenton.Example { public class ExampleClassContinue reading “Mocking a Service Proxy in .NET with Rhino Mocks”