Unit Testing EF Data With Core 2.0

I’ve discussed using the in-memory database object for Entity Framework in the blog post titled: Dot Net Core In Memory Unit Testing Using xUnit. That was for .Net Core 1.1.  Now I’m going to show a larger example of the in-memory database object for .Net Core 2.0.  There is only one minor difference in the … Read moreUnit Testing EF Data With Core 2.0

Unit Testing EF Data With Moq

Introduction I’ve discussed using the in-memory Entity Framework unit tests in a previous post (here).  In this post, I’m going to demonstrate a simple way to use Moq to unit test a method that uses Entity Framework Core. Setup For this sample, I used the POCOs, context and config files from this project (here).  You … Read moreUnit Testing EF Data With Moq

XML Serialization

Summary In this post I’m going to demonstrate the proper way to serialize XML and setup unit tests using xUnit and .Net Core.  I will also be using Visual Studio 2017. Generating XML JSON is rapidly taking over as the data encoding standard of choice.  Unfortunately, government agencies are decades behind the technology curve and … Read moreXML Serialization

Mocking Your File System

Introduction In this post, I’m going to talk about basic dependency injection and mocking a method that is used to access hardware.  The method I’ll be mocking is the System.IO.Directory.Exists(). Mocking Methods One of the biggest headaches with unit testing is that you have to make sure you mock any objects that your method under … Read moreMocking Your File System

Dot Net Core Using the IOC Container

I’ve talked about Inversion Of Control in previous posts, but I’m going to go over it again.  If you’re new to IOC containers, breaking dependencies and unit testing, then this is the blog post you’ll want to read.  So let’s get started… Basic Concept of Unit Testing Developing and maintaining software is one of the … Read moreDot Net Core Using the IOC Container

Dot Net Core In Memory Unit Testing Using xUnit

When I started using .Net Core and xUnit I found it difficult to find information on how to mock or fake the Entity Framework database code.  So I’m going to show a minimized code sample using xUnit, Entity Framework, In Memory Database with .Net Core.  I’m only going to setup two projects: DataSource and UnitTests. … Read moreDot Net Core In Memory Unit Testing Using xUnit

Mocking HttpContext – Adding Sessions

Summary In one of my previous posts (See: Mocking HttpContext), I created a HttpContext factory and a mocked HttpContext object that can be used to simulate the HttpContext.Current object used by methods under a unit test.  In this post, I’m going to add the Session capabilities to this object so you can unit test your … Read moreMocking HttpContext – Adding Sessions