This post continues on Unit testing and code coverage for ASP.NET Web API (1/2).
Much about the topic is inspired from the truly magnificent book “The Clean Coder: A Code of Conduct for Professional Programmers” of Robert C. Martin Series, which of course, I definitely recommend.
Specifying the low level architecture
Professional software developers always test their code. It is part of our daily job, we should be proud and flexible on writing tests. It is a proof that our code actually follows our intent, at least on system’s low level. There are many more tests to be followed, composing a testing strategy, but this post is going to focus solely on one aspect of such strategy, the unit tests.
This is the second post in the series on Web API. Topic is TDD and code coverage, so I am going to demonstrate how to unit test your core code, as well as the API code and in the end, how to measure the code coverage you achieved on testing your code base. First, I am going through the changes needed to take place in the application architecture and then I will go to tests, so this article is divided into two parts.
In this post we are going to talk a little bit about OWIN. What is it, how can we use it with ASP.NET Web API to expose API endpoints, as well as how to secure those endpoints.
The application uses OWIN to self-host the Web API as well as ASP.NET Identity as underlying membership mechanism. Users can fetch public data from /api/people endpoint, as well as secured private data from /api/user endpoint. The latter one is to demonstrate security in Web API.
Let’s say we have the following, one class named
Implementor which has an
DoWork of the class, we call the interface’s method, but we also call another method, which comes by casting the dependency to a derived interface.
All, good, we go ahead and create a unit test project, adding the Moq package as well, in order to mock dependencies.
In this post we are going to talk about AngularJS, Typescript, SystemJS.
Also, we are going to work with typings definitions as well as SystemJS JSON plugin to load JSON configuration in front end code.
In this post, we are going to focus on some pretty basic stuff, like setting up the application and getting it working. Posts will become more advanced during the series progress. Feedback is always appreciated, so please, if you have any thoughts on how this and future posts can be improved, leave your comments below.
Who is this article for
If you are a beginner on Angular2, if the framework is something new for you and you wish to learn more about it, this is the article for you. We are going to setup Angular2 with TypeScript on VSCode, getting a very basic hello world application.