Moq has a set of methods specific to stubbing and verification of properties. In this post I’m going to go over each one of them, and explain when and why to use them. I also discuss their differences and in what situation we might want to use them. Let’s assume we have an interface with …
C#
Asp.Net Core Model Binding: Controlling The Binding Source
Asp.Net Core Model Binding has a set of attributes that gives us the ability to control from what source we want to receive the binding data. In this post I’m going to go through these attributes and show how and when you can use them. Default Model Binder Behavior The default behavior of model binder …
LINQ To Entities – Balance Between Cost Of Database Calls And Data Volume
I was performance tuning some of the rushed queries on one of the web apps that I’m currently work on. What I’ve realized was writing efficient LINQ queries requires a little more effort than I thought. In this post I’m going to show you some of the issues I’ve encountered and the lessons I’ve learned …
xUnit Theory: Working With InlineData, MemberData, ClassData
xUnit support two different types of unit test, Fact and Theory. We use xUnit Fact when we have some criteria that always must be met, regardless of data. For example, when we test a controller’s action to see if it’s returning the correct view. xUnit Theory on the other hand depends on set of parameters …
Mock HttpClient Without Wrapper Using HttpMessageHandler
There is a lot of discussion on github about why HttpClient doesn’t have an interface. Despite the long winded discussion on github about the subject, I think mocking the HttpClient isn’t that hard. We can solve this problem with a wrapper, but wrappers are not a good idea when we can avoid them. Partly because …
12 Visual Studio Extensions You Might Find Useful
I previously wrote about some Visual Studio extensions that I though was most useful here. I think that list still stands. But in this post I’m going to introduce less known extensions that I think might be useful, but not essential. Viasfora Viasfora adds tons of features to your code formatting experience. From code rain …
Dynamically Building JSON Tree For Use In Javascript Components Using C#
These days, many JavaScript components use JSON when it comes to working with data, the reason is obvious enough, but some components that build some kind of tree structure like this one, are going to need a JSON tree. Building a static JSON tree is easy, but how do you build a dynamic JSON tree …
How To Show Currently Online Users (Members) Using Asp.Net MVC And Identity
How To Show Currently Online Users (Members) Using Asp.Net MVC Identity Introduction In this post, I’m going to show how to implement online users feature using Asp.Net MVC Identitiy. In the old Membership system of ASP.NET, things were a little easier, you could get the list of all users, also you could see who is …
Implementing Search Without Convoluted If Statements In Asp.Net MVC
In the beginning, when I start to learn C# and Asp.Net MVC, building search form was a complicated thing to do for me. The more criteria I’ve had for a search form, the harder it would get, but it was hard because I didn’t use the proper tools to do my job. Back then, I …
Customizing ELMAH To Prevent It From Logging Unnecessary Errors Using Entity Framework and ASP.Net MVC
Couple of months ago, I needed to use ELMAH in one of my project (in case you haven’t heard about it, you can see what it can do for you here), but the component out of the box had some problem in my opinion. for example when an error occurs, it goes ahead and log …