Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

11 total results found

Duplicating .NET Core DI

.NET

NOTE: If you are looking for how to access DI services, see this: HowTo Access DI Services Here are the steps to duplicating the .NET Dependency Injection process, to create a ServiceProvider instance. This is especially useful in unit testing, for classes an...

unittests
programming
dotnet
.net
DI
testing
IServiceProvider

Unit Testing with IServiceProvider

.NET

When you create unit tests for class types that directly use DI to retrieve dependencies, you will need a way to give them a reference to a service provider (IServiceProvider). This is transparently done by the runtime.But, we have to mimic it for unit testin...

programming
dotnet
.net
testing
unittests
DI

NET Core Test API

.NET

We have a standing REST API with various endpoints for simulating different method types, return errors, and such. It’s Swagger page is, here: http://192.168.1.201:4250/swagger/index.html

.net
dotnet
programming
infrastructure
testing

Unit Testing for an Exception

.NET

Sometimes, a unit test needs to ensure a particular exception type occurs. Here’s how to check that a particular exception and message occurs. The catch is that, when executing code inside a unit test framework, such as MSUnit, any exception thrown by code i...

testing
unittests
programming
.net
dotnet

C# Unit Tests with Async Task Signature

.NET

When writing unit tests, it’s good to standardize as much as possible.This includes the method signature for each test cases, such as this: // Test_1_1_1 Describe the test... [TestMethod] public async Task Test_1_1_1() { // Do some testing... ... ...

programming
.net
dotnet
unittests
testing

Unit Test Cheat Sheet

.NET

Here’s a list of elements for unit testing in Visual Studio using MSTest. Documentation for Visual Studio Testing is here: GitHub - microsoft/vstest-docs: Documentation for the Visual Studio Test Platform. Necessary Packages The following packages are neces...

programming
.net
dotnet
testing
unittests

C# Unit Test Template Classes

.NET

If you are using MSTest as your testing framework, and want to leverage the test functionality from OGA.Testing.Lib, here are the minimal classes and structure you will need. For a cheat-sheet on MSTest framework usage, see this: Unit Test Cheat Sheet Depend...

.net
programming
dotnet
unittests
testing

.NET Framework Unit Testing Issues

.NET

Since we have some libraries that still output to NET Framework targets, some workarounds are required because of some design choices that have been made in the MSTest library and Test Explorer. MSTest Project Styles (SDK vs Non-SDK) NOTE: This only applies ...

.net
programming
testing
dotnet
unittests

Mocking a DBContext for Testing

.NET

The easiest means to mock a data context for testing, is to use an in-memory database. An in-memory database is known by its string-name within a process. Each data context accessing the database instance must use its name, via options. A few things are need...

.net
programming
dotnet
testing

Unit Tests with PostgreSQL Backends

.NET

In order to easily stand up a Postgres database for unit and integration testing, we need a class that can encapsulate the effort, to an easy call surface. Below we have a helper class that will manage the life-cycle of a test database, in PostgreSQL. Given ...

postgres
.net
programming
testing
dotnet
database

Unit Testing Conventions

.NET

Suppress Async Warning Project-Wide Since we have several calls to base classes for diagnostics and such that are async, it's a good idea to standardize on all Test methods be async. The problem is that not every test method contains an awaited call. so, we ...

.net
dotnet
testing
programming
unittests