Use Moq CallBack to Verify Object Parameter

Our repositories accept domain models as parameter to save them to the database. Moq’s verify works greatly if the method has primitive types like string, int, and bool, not so good at showing error message if the paramter is an object.

Installing Ubuntu on Windows 10

It’s really nice that I can use linux shell on windows. One of big part of me using MacBook was to have linux / unix-like shell and development environment.

Unit Testing With ASP.NET Core

It’s important that your unit test run against public interface of module. Otherwise, you do not test behaviour but your implementation of the behaviour. In case of APIs, it’ll be API interface via HTTP.

Get last item from List in F#

In C#, you use bang (!) to negate a boolean expression. Unfortunately, not in F#. it’s “not”

Fix ASP.NET Core port number on Service Fabric

If you create a stateless asp.net core api as service fabric service, the port number changes each time you restart the service fabric service. It’s quite annoying that your postman requests start failing because the port number has changed. To fix it, you have to override the resource, specifying the port number.

Configuration in ASP.NET Core

When you create stateless service fabric asp.net core api, the template doesn’t add configuration builder by default. I’ve spent about an hour pulling my hair why it doesn’t load appsettings.json on start up. So, Add it first.

A journey into ASP.NET Core CORS (Cross Origin Resource Sharing)

A quick note. I may turn this into a proper blog post.

Nginx as Reverse proxy for ASP.NET Core on Local Windows machine

NginX is a basket full of interesting features, but here, I’ll focus on using it as reverse proxy.

양치기들에게 나타나신 하나님

Luke 2:8-9 “And there were shepherds living out in the fields nearby, keeping watch over their flocks at night. 9 An angel of the Lord appeared to them, and the glory of the Lord shone around them, and they were terrified.”

False alarm from bots

I'm on call this week, and whenever there's alert, it comes to my mobile. I've had Error rate > 5% alert from PagerDuty the other day. I've acknowledged the alert, (otherwise it keeps sending me the alerts) and investigated it.

A public action method 'Login' was not found on controller 'xxxxWeb.Controllers.HomeController'

It was interesting. The action method definitely exists there, but we had 5 errors instantly. After investigation and some googling, it turned out that excel spreadsheet and some crawling bot were hitting the endpoint with HEAD and OPTIONS verb.

Why? I don't know, but the fix was simple. Currently, Login was constrained to GET. Simply take off the constraint and the page will serve HEAD and OPTIONS very well.

It's fun to be a on-call engineer. You can see loads of things you haven't expected to see, in real world, on production server.