Navigate / search

NDepend – short review

Sometime ago I have been asked by Patrick Smacchia to write short review of his tool – NDepend. I believe that most of you know this tool. It is a swiss army knife in scope of code analysis. Capacity of this tool is enormous. I wanted to fulfil this request in a professional way. So, I needed to learn how to use this tool before writing any word regarding it. And it was not so easy task. This tool has so many features and possibilities of customisation… After two months of using it I can say that still I am not so advanced user of it.

I will try to do my best… Read more

Caching in Azure Function – how you can use Redis

I believe that you should know that Microsoft has prepared some set of components that can be used for integration purposes. You are able to consume the following services in our function: Azure Storage, Azure Event Hubs, Azure Service Bus, Azure Mobile Apps, Azure Cosmos DB, Azure Notification Hubs, Twilio, SendGrid. On the one hand this list is not so big. On the other one you can address with those services a lot of typical scenarios. But sometimes you need to do something more.

Today I would like to share with how easily you can use Redis cache in Azure Function. You should start thinking what for we need to do that. Probably you heard that Azure Functions should be stateless, atomic, small, fast, … But sometimes you need to do something that violate those rules. Read more

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.

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

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

.net DD 2016 – materials

Since few weeks ago it is possible to watch sessions from .NET DeveloperDays 2016 on YouTube channel. I think that the best speaker of that conference edition was Ted Neward. I recommend his closing keynote session. It was really great. It is hard to say that this session was technical one. I would rather say that it was more philosophical. During it Ted showed importance of context in scope of taking correct decisions. He provided a lot examples that showed difficultness of taking this one correct solution / decision. It is hard to describe it. I recommend you to watch it.