Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yogyogi/asp.net-core-unit-testing-with-xunit

How to perform Unit Testing with xUnit in ASP.NET Core
https://github.com/yogyogi/asp.net-core-unit-testing-with-xunit

aspnetcore integration-testing moq selenium selenium-csharp selenium-tests selenium-webdriver testing ui-testing unit-test unit-testing xunit

Last synced: about 3 hours ago
JSON representation

How to perform Unit Testing with xUnit in ASP.NET Core

Awesome Lists containing this project

README

        

# ASP.NET Core Unit Testing with xUnit

I perform Unit Testing for my ASP.NET core app with xUnit framework. These are divided into 6 topics:

1. Unit Testing with xUnit in ASP.NET Core
2. Moq and xUnit for Unit Testing Controllers in ASP.NET Core
3. Unit Testing of Web API with xUnit and Moq
4. How to tests Entity Framework Core Codes
5. How to perform Integration Testing in ASP.NET Core
6. Automated UI Testing with Selenium in ASP.NET Core

I have also written separate tutorials for each of these 6 types of tests. Kidly refer them.

# Tutorial 1
How to perform Unit Testing with xUnit in ASP.NET Core

## Contents
1. Fact, Theory, InlineData
2. Project Setup
3. Adding Project for Unit Testing
4. Adding Project Reference
5. Adding xUnit Packages
6. Testing a C# class functionality in xUnit
7. Arrange, Act, Assert
8. Running the Test in Test Explorer
9. [Theory] and [InlineData] attributes
10. Assert class Important Methods
11. Testing Controller with xUnit
12. Writing Test Methods for controllers in xUnit
13. How to Debug Test Methods with Breakpoints

# Tutorial 2
How to use Moq and xUnit for Unit Testing Controllers in ASP.NET Core

## Contents
1. Setup
2. Moq
3. In Memory Database
4. Creating Database Operations Class
5. Creating a Simple CRUD Operations feature in ASP.NET Core
6. Testing Controller with Moq and xUnit
7. Unit Tests for “Create” actions
8. Unit Tests for “Read” action
9. Unit Tests for “Update” action
10. Unit Tests for “Delete” action

# Tutorial 3
Unit Testing of Web API with xUnit and Moq

## Contents
1. Project setup install xUnit and Moq
2. Create Web API
3. Testing Web API with xUnit and Moq

# Tutorial 4
How to tests Entity Framework Core Codes

## Contents
1. Setup of the App and In-Memory database for Testing
2. In Memory Database
3. Database Context and Model class
4. Creating a Simple CRUD Operations feature in ASP.NET Core
5. Testing Controller with xUnit
6. Seeding the Database
7. Unit Tests for “Create” actions
8. Unit Tests for “Read” action
9. Unit Tests for “Update” action
10. Unit Tests for “Delete” action

# Tutorial 5
How to perform Integration Testing in ASP.NET Core

## Contents
1. Project Setup
2. Creating Test Server with WebApplicationFactory class
3. Integration Test Class
4. Integration Testing of the Read Action
5. Integration Testing of the CREATE Action (HTTP GET type)
6. Invalid Model – Integration Testing of the CREATE Action (HTTP POST type)
7. Valid Model – Integration Testing of the CREATE Action (HTTP POST type)
8. AntiForgeryToken in Integration Testing
9. How to include AntiForgeryToken in Integration Testing
10. Modify the Integration Test for ValidateAntiForgeryToken

# Tutorial 6
Automated UI Testing with Selenium in ASP.NET Core

## Contents
1. Project Setup and Selenium Installation
2. Writing UI tests with Selenium
3. UI Test to Check if the View is rendered
4. UI Test to Check browser behaviour when Model is invalid
5. UI Test to Check browser behaviour for Valid Model

## Want to support me ?

Your support of every $5 will be a great reward for me to carry on my work. Thank you!

Buy Me A Coffee
Paypal Me