LINQ

Moq.EntityFrameworkCore package

From yesterday you can download package that will help you with mocking DbSet<TEntity> when you are using Moq. You can find sources and short instruction on GitHub portal or download compiled version from NuGet. New package works in the same way as Moq.EntityFramework.Helpers.

By |2017-10-15T22:51:45+02:0015 October 2017 |ASP.NET Core, C#, Projects, Testing|0 Comments

Moq.EntityFramework.Helpers NuGet package

As you probably know I wrote two articles about mocking DbSet<TEntity> with Moq: synchronous calls – Mocking DbContext and DbSet with Moq asynchronous calls – EntityFramework – asynchronous queries unit tests I combined those solution to one library and published in on NuGet – Moq.EntityFramework.Helpers. […]

By |2017-03-07T22:07:45+02:007 March 2017 |C#, Extras / Tools, Projects, Testing|2 Comments

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; [...]

By |2017-03-05T09:04:23+02:005 March 2017 |.net|0 Comments

Mocking DbContext and DbSet with Moq

I believe that during your work with unit tests with applications that are using database for data storage you will need to isolate layer that is responsible for providing data. In this example I will use Entity Framework as ORM. Below you can find main elements of solution: public class User { public int Id { get; set; } public string Login { get; set; } public string Name { get; set; } public string Surname { get; set; } public bool AccountLocked { get; set; } public virtual List<Role> Roles { get; set; } } public class UsersContext [...]

By |2016-02-09T22:32:03+02:0031 January 2016 |Testing|11 Comments

LINQ is not so bad

Increasingly, the projects begin to use LINQ and begin to see advantages. Not only, that in this way can write some code, and gain some clarity. Below are some examples, which slowly skim through the LINQ. For demonstration purposes, let’s create a class Person, which objects will be represented by a person. […]

By |2013-06-10T14:05:25+02:0031 January 2011 |C#|3 Comments

List of installed applications

Sometimes there is a need to find information about what software is installed on your computer. For example, we want to know, if anyone has already installed the program and where it is installed. This knowledge is needed, example, if you add a file to a directory with the program already installed. The simplest example is to write different kinds of plugins. The problem does not occur if the application has been installed in the default directory, we know, but this can no longer guarantee. […]

By |2012-06-15T22:19:27+02:0010 January 2011 |C#|1 Comment