Mocking an HttpClient using an HttpClientHandler

Recently, I wrote a .NET client for Open Exchange Rates, a service to get exchange rates for more than 100 currencies. You can find it on GitHub. The code is pretty simple, it simply calls the api of Open Exchange Rates using an HttpClient class and deserialize json using Json.NET. I don't want to show you this code in this post, but how you can add some tests to this kind of code. Yes, you must test your… [read more]

Starting a http file server from the file explorer using .NET Core 2.0 and Kestrel

The previous version of this post was using .NET Core 1.1. Today, we'll do the same but using .NET Core 2.0. The main change concern the web server startup method. If you’re developing html/js applications and want to test locally (file:///c:/...), many times your browser will prevent you from using some functionalities such as accessing local files using XMLHttpRequest. In Google Chrome, you can disable… [read more]

Upload files and directories using an input, drag and drop, or copy and paste with HTML5

Many websites have a form to upload a file. For some sites, such as OneDrive or Google Drive, uploading files is a major feature. As time went on, webpages are more and more interactive. So, users expect more interactions such as dragging and dropping files or directories or pasting screenshots. Let's see what browsers provide to upload files! Basic file input The basic way is by using a form and an input… [read more]