no dogma blog
no dogma blog
Blog Posts
Podcast
Web API Lambda Course
Polly Course
Photos
Contact
Support this Site
About
RSS
Light
Dark
Automatic
Unit Test
Testing Your Code When Using Polly
Full source code here. Want to learn more about Polly? Check out my Pluralsight course on it. When developing an application with Polly you will also probably want to write some unit tests.
Mar 10, 2019
#
Polly
,
Testing
,
Unit Test
Using the HttpClientInterception to Test Methods That Use a HttpClient
Full source code available here. In my previous post I showed a way of testing a controller that uses a HttpClient. I had to mock the HttpMessageHandler pass that to the HttpClient and set a bunch of properties.
Jan 13, 2018
#
HttpClient
,
Testing
,
Unit Test
,
WebApi
,
WebApi2
Unit Testing a Method That Uses HttpClient
Full source code available here. In this post I’m going to show you how to test an action method of controller that uses a HttpClient. When performing this test you want to isolate just the code of the action method for testing, you want to remove the dependency on the HttpClient.
Dec 19, 2017
#
Dependency Injection
,
HttpClient
,
HttpMessageHandler
,
Unit Test
Unit testing Entity Framework Core Stored Procedures
Full source code available here. Entity Framework Core has made unit testing CRUD functions much easier, see here for an example of using the In Memory Database, it allows you to search, add, remove and update rows.
Nov 21, 2017
#
Entity Framework Core
,
Stored Procedure
,
Unit Test
Entity Framework Core 2 Unit Testing in .NET Core 2
Full source code available here. Unit testing Entity Framework used to be quite a chore, but over the past few years it has become significantly easier. In this post I’m going to show you how to use the InMemory database with named instances.
Sep 25, 2017
#
dotNet Core 2
,
Entity Framework Core
,
Unit Test
,
WebApi
Unit Testing .NET Core 2 Web Api
Full source code available here. Unit testing Web API controllers in .NET Core 2 is very easy. I have very simple GET and POST methods. 1[Route("api/[controller]")] 2public class ValuesController : Controller 3{ 4[HttpGet] 5 public async Task<IActionResult> Get() 6 { 7 // imagine some db logic 8 List<string> values = new List<string>() { "value1", "value2" }; 9 return Ok(values); 10 } 1112[HttpPost] 13 public async Task<IActionResult> Post([FromBody]string value) 14 { 15 // imagine some db logic 16 return Created("", value); 17 } 18} Add an xUnit Test Project to your solution.
Sep 9, 2017
#
dotNet Core 2
,
Unit Test
,
WebApi
Cite
×