- Follow MSDev.pro blog on WordPress.com
Follow us
-
Recent Posts
Categories
Recent Comments
Archives
Category Archives: .Net
Unit testing your Repositories
The problem We have created our data layer, and of course we want to test it. It is very hard to use a (physical) database to test your code. There are some problems with this (commonly used) approach: Unit tests … Continue reading
Posted in .Net, Architecture, Codeproject, Development, Entity Framework, Testing
Tagged repositories
1 Comment
Creating an OData V4 service
I’m writing an agenda application, where the data can be delivered to the calendar control using either REST or OData V4. I choose the latter because this will allow for much more flexibility afterwards. I already have an MVC 5 … Continue reading
Posted in .Net, Codeproject, Development, MVC, MVC5, Web API
Tagged OData v4; NuGet; Delta; Entity Framework; REST
8 Comments
Using the repository pattern
In most applications database access is necessary. In .NET there are 2 main ways of doing this: ADO.NET or using the Entity Framework. Of course there are great 3rd party libraries like NHibernate that do the trick as well, and … Continue reading
Posted in .Net, Architecture, Codeproject, Development, MVC, WCF
Tagged Repository; separation of concerns
3 Comments
Mocking functionality using MOQ
What is wrong with this code? class Program { static void Main(string[] args) { DateTime dob = new DateTime(1967, 7, 9); int days = CalcDays(dob); Console.WriteLine($”Days: {days}”); } private static int CalcDays(DateTime dob) { return (DateTime.Today – dob).Days; } … Continue reading
Grasshopper Unit testing
“I have created my code, split out some functionality and written the tests. But the mocks have become a real mess, and much more work than I had thought it would be. Can you help me, Sensei?” “Of course. Show … Continue reading
Posted in .Net, Codeproject, Development, Methodology, Testing
Tagged dependency injection, DI, separation of concerns
3 Comments
Let IntelliTest generate your tests!
We corrected our function to calculate the GCD so that it now runs correctly. But is the function correct in all the cases? Have we really tested everything? It would be nice if there was a tool that could tell … Continue reading
Posted in .Net, Codeproject, Debugging, Development, Methodology, Testing
Tagged IntelliTest;Pex;Assert;GCD;TDD
Leave a comment
How to set up a Parameterized Unit Test
In my previous post we saw how to set up unit testing using Visual Studio. The code we want to test is a (simple) function to calculate the greatest common divisor, and we wrote our first test. The test we … Continue reading
Posted in .Net, Codeproject, Debugging, Development, Methodology, Testing
Tagged CSV, Data source, GCD, Parameterized Unit Test, TDD
Leave a comment
Setting up unit testing
Introduction In the previous posts I talked about unit testing. I gave some background, and I explained the flow of Test-driven Development (TDD). So now is the time to set things up. In this article I will use the calculation … Continue reading
Posted in .Net, Codeproject, Development, Methodology, Testing
Tagged Visual Studio;unit test
3 Comments
Could not load file or assembly ‘System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’
When creating a new MVC5 application using VS2013 I got the following error: Could not load file or assembly ‘System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception … Continue reading
Posted in .Net, Development, MVC, MVC5, Web API
2 Comments
“Object reference not set to an instance of an object” when building my cloud project
In my Azure project I have a worker role and a wcf role. When compiling it failed (with no obvious reason) with this message in the output window: Error: Object reference not set to an instance of an object There … Continue reading
Posted in .Net, Azure, Development
Leave a comment