This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var fault = new SocketException(errorCode: 10013); | |
| var policy = MonkeyPolicy.InjectFault( | |
| fault, | |
| injectionRate: 0.05, | |
| enabled: () => isEnabled() | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Before | |
| public class Person | |
| { | |
| private readonly string _firstName; | |
| private readonly string _surname; | |
| private readonly int _age; | |
| public Person(string firstName, string surname, int age) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Arrange | |
| var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true}; | |
| new HttpRequestInterceptionBuilder() | |
| .Requests() | |
| .ForHttps() | |
| .ForHost("bbc.co.uk") | |
| .ForPath("/news") | |
| .Responds() | |
| .WithStatus(500) | |
| .RegisterWith(options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Arrange | |
| var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true}; | |
| new HttpRequestInterceptionBuilder() | |
| .Requests() | |
| .ForHttps() | |
| .ForHost("bbc.co.uk") | |
| .ForPath("/news") | |
| .Responds() | |
| .WithStatus(500) | |
| .RegisterWith(options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Arrange | |
| var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true}; | |
| new HttpRequestInterceptionBuilder() | |
| .Requests() | |
| .ForHttps() | |
| .ForHost("bbc.co.uk") | |
| .ForPath("/news") | |
| .Responds() | |
| .WithStatus(500) | |
| .RegisterWith(options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ApiController] | |
| [Route("api/[controller]")] | |
| public class ReposController : Controller | |
| { | |
| private readonly IGitHub _github; | |
| public ReposController(IGitHub github) | |
| { | |
| _github = github; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Fixture<TStartup> : WebApplicationFactory<TStartup> where TStartup : class | |
| { | |
| public HttpClientInterceptorOptions InterceptorOptions { get; } = | |
| new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true}; | |
| protected override void ConfigureWebHost(IWebHostBuilder builder) | |
| { | |
| builder.ConfigureServices(s | |
| => s.AddSingleton<IHttpMessageHandlerBuilderFilter, InterceptionFilter>( | |
| _ => new InterceptionFilter(InterceptorOptions))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ControllerTests : IClassFixture<Fixture<Startup>> | |
| { | |
| private readonly Fixture<Startup> _fixture; | |
| public ControllerTests(Fixture<Startup> fixture) => _fixture = fixture; | |
| [Fact] | |
| public async Task ReturnsOrganizationRepositories() | |
| { | |
| // Arrange |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #if IS_LINUX | |
| [Fact] | |
| public void ShouldlyApi() | |
| { | |
| ... | |
| } | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Fact(Skip = "Doesn't work at the moment")] | |
| public void ClassScenarioShouldFail() | |
| { | |
| ... | |
| } |