Integrating the #WebAPI HttpClient and ApiController in a single test

In the two previous blog posts I showed how to unit test and ASP.NET WebAPI controller and how to unit test the client side code depending on the HttpClient class. Both unit tests are perfectly valid but as so often just adding unit tests can be deceptive. After all testing an ApiController by just calling the methods makes it perfectly possible to call them in such a way that would never be possible using a real HTTP request. So in order to complete out testing we should test the integration of the client and server parts using an integration test. … Continue reading Integrating the #WebAPI HttpClient and ApiController in a single test

Unit testing code depending on the ASP.NET WebApi HttpClient

In a previous post I showed how to unit test an ASP.NET WebAPI Controller. But with a REST service there is both a client and a service component. Assuming for a moment the client part is also written in C# we should test that as well. In this case the client application contains the following class to load books from the REST WebAPI controller: 1: public class BooksClient 2: { 3: private readonly HttpClient _httpClient; 4:  5: public BooksClient(HttpClient httpClient) 6: { 7: _httpClient = httpClient; 8: BaseUrl = new Uri("http://localhost:63895/api/books/"); 9: } 10:  11: public Uri BaseUrl { get; … Continue reading Unit testing code depending on the ASP.NET WebApi HttpClient

Filtering the data in an AngularJS ngRepeat element

Index: Getting started with AngularJS Creating an AngularJS Controller The AngularJS $scope is not the MVC Model Using repeating elements in AngularJS Filtering the data in an AngularJS ngRepeat element Using the AngularJS FormController to control form submission Creating an AngularJS Directive Using the DOM in an AngularJS application To SPA or not to SPA   Showing a list of items like in the previous post is nice but if the list is large most users appreciate the possibility to search in it. Turns out that AngularJS has that already build in so it is really simple to do.   … Continue reading Filtering the data in an AngularJS ngRepeat element

Unit testing a ASP.NET WebAPI controller

  Update: If you are using the ASP.NET WebAPI 2 see the new post here.   One of he goals of the ASP.NET WebAPI is to make REST style API controllers more testable than more traditional WCF services where in the past. For the most part that is true but there are cases where an ApiController depends on the actual incoming request and its data and things can become a bit more difficult. Testing a simple ApiController that gets data Suppose we have the following ASP.NET WebAPI Controller with two Get methods, the first returns the complete list of books … Continue reading Unit testing a ASP.NET WebAPI controller

Using repeating elements in AngularJS

Index: Getting started with AngularJS Creating an AngularJS Controller The AngularJS $scope is not the MVC Model Using repeating elements in AngularJS Filtering the data in an AngularJS ngRepeat element Using the AngularJS FormController to control form submission Creating an AngularJS Directive Using the DOM in an AngularJS application To SPA or not to SPA   In the previous  posts I showed how to get started with AngularJS and use some of the basic AngularJS directives to data bind. In these examples I uses a really simple single element to bind to. However in lots of business cases you really … Continue reading Using repeating elements in AngularJS