Navigate / search

Azure Functions – Lessons learned

Nowadays all topics related to Cloud and Serverless terms have become very popular. One of such elements are Azure Functions. Microsoft defines it as:

Azure Functions is a solution for easily running small pieces of code, or “functions,” in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. Functions can make development even more productive, and you can use your development language of choice, such as C#, F#, Node.js, Python or PHP. Pay only for the time your code runs and trust Azure to scale as needed. Azure Functions lets you develop serverless applications on Microsoft Azure.

And really I could write a lot about comfort of it usage, easiness of implementation and other features that are great in this solution. Azure Functions works perfect when you do not need to have huge backend. I tested this scenario many times and I was always satisfied.

Of course, at the beginning I made some mistakes and I would like to write about two most important ones. Read more

FluentValidation.Validators.UnitTestExtension version 1.1

I just managed to publish new version of packgage FluentValidation.Validators.UnitTestExtension. This package allows you to write unit tests for Fluent Validators in more effective way.

With version 1.1 following changes have been introduced:

  • support for new version of FluentValidation 7.*
  • new verifiers that check configuration of ScalePrecisionValidator and RegularExpressionValidator.

More information about project is available on GitHub.

I am writing good code – InfoMEET Katowice 2017

On this Saturday (20.05) you will be able to listen to me on  InfoMEET Katowice 2017. Subject of my presentation is I am writing good code – how you should protect code quality in your project? During presentation I will explain what software quality means and show you how you can easily increase its level. But this is not all. I will focus on practical part and I will show you how tools can help us with taking care of our code. We will learn how you should do it in effective way. So you could gain the biggest benefit with the smallest cost.

You are welcome!

EntityFramework – asynchronous queries unit tests

Sometime ago I described how we can use Moq to unit tests elements of DbContext – please check post Mocking DbContext and DbSet with Moq. Unfortunate that post didn’t covered all issues related to that topic. I didn’t write about unit tests asynchronous queries. Today I want to come back to this issue.

We can treat a previous post as a starting point. We already have some code that help us to mock DbSet<T>. And right now we will extend that code to support asynchronous queries. It is very easy. We need only to implement IDbAsyncQueryProvider interface:

public class InMemoryAsyncQueryProvider<TEntity> : IDbAsyncQueryProvider
  private readonly IQueryProvider innerQueryProvider;
  internal InMemoryAsyncQueryProvider(IQueryProvider innerQueryProvider)
    this.innerQueryProvider = innerQueryProvider;

  public IQueryable CreateQuery(Expression expression)
    return new InMemeoryAsyncEnumerable<TEntity>(expression);

  public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
    return new InMemeoryAsyncEnumerable<TElement>(expression);

  public object Execute(Expression expression)
    return this.innerQueryProvider.Execute(expression);
  public TResult Execute<TResult>(Expression expression)
    return this.innerQueryProvider.Execute<TResult>(expression);

  public Task<object> ExecuteAsync(Expression expression, CancellationToken cancellationToken)
    return Task.FromResult(Execute(expression));

  public Task<TResult> ExecuteAsync<TResult>(Expression expression, CancellationToken cancellationToken)
    return Task.FromResult(Execute<TResult>(expression));

Read more

Get Noticed! – Short introduction

A few days ago second edition Get Noticed! has started. From the beginning I wanted to be part of this competition community. The idea is great! Unfortunate as usual taking decision was not so easy. The main blocker was my calendar. In that time all of my weekends are busy. Moreover I am planning two foreign trips. One of them will be longer. Finally I decided to take part in it – a small motivation factor was that I tried to convince Jurka to take part in this competition. Finally I decided to take part in it. It seems that it will be the first time when I will take a laptop with me on holidays. I hope I will manage to survive to end of competition.

Let’s switch to issue that I would like to solve.

We can look at this from two perspectives. First – motivation. From over a year I am trying to switch into web technologies. In general I am getting better with it. But still I haven’t started any project from scratch jet. I always joined to project that were already ongoing. And this completion can be great possibility to go through all stages of application creation. Also, I would like to move out from my comfort zone and try new technologies. I am planning to use ASP.NET Core as backend and Angular2 (maybe Angular4) as frontend. Of course, everything will be hosted on Azure.

And finally – the idea. I would like to build an application that will provide information about NuGet package downloads. Also is should be possible to place some kind of button / picture on GitHub that will inform about current number of downloads of our package.

Upgrade from ASP.NET Core 1.0.x to 1.1

New version of .NET Core 1.1 has been published on 17th November. Together with it new versions of ASP.NET and EntityFramework have been introduced. I wanted to update my application to new framework. I thought that it will be very easy. Unfortunate my application didn’t start after update. Moreover it didn’t even compile.

Let’s start from the beginning. The first thing you need to do is downloading and installing new SDK and Runtime. You will find installers on .NET Core Downloads webpage.

Read more

Speeding up AutoFixture

I already mentioned about AutoFixture in one of the posts – Lightning talk – Autofixture. Main goal of this library is to help us with reduction of Arrange part of unit tests. With this library we can focus on the main scenario of unit test instead of focusing on building objects that are needed for test. Moreover AutoFixture will protect us against modification of classes that are being used in our unit tests.

But it is not perfect. Sometimes duration of unit tests can increase dramatically. Especially when you are creating objects used by EntityFramework. Read more