Skip to content

Instantly share code, notes, and snippets.

View josephwoodward's full-sized avatar

Joseph Woodward josephwoodward

View GitHub Profile
public class ControllerTests : IClassFixture<Fixture<Startup>>
{
private readonly Fixture<Startup> _fixture;
public ControllerTests(Fixture<Startup> fixture) => _fixture = fixture;
[Fact]
public async Task ReturnsOrganizationRepositories()
{
// Arrange
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)));
[ApiController]
[Route("api/[controller]")]
public class ReposController : Controller
{
private readonly IGitHub _github;
public ReposController(IGitHub github)
{
_github = github;
}
@josephwoodward
josephwoodward / hc3.cs
Last active May 22, 2020 00:23
hc3.cs
// Arrange
var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true};
new HttpRequestInterceptionBuilder()
.Requests()
.ForHttps()
.ForHost("bbc.co.uk")
.ForPath("/news")
.Responds()
.WithStatus(500)
.RegisterWith(options);
// Arrange
var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true};
new HttpRequestInterceptionBuilder()
.Requests()
.ForHttps()
.ForHost("bbc.co.uk")
.ForPath("/news")
.Responds()
.WithStatus(500)
.RegisterWith(options);
// Arrange
var options = new HttpClientInterceptorOptions {ThrowOnMissingRegistration = true};
new HttpRequestInterceptionBuilder()
.Requests()
.ForHttps()
.ForHost("bbc.co.uk")
.ForPath("/news")
.Responds()
.WithStatus(500)
.RegisterWith(options);
// Before
public class Person
{
private readonly string _firstName;
private readonly string _surname;
private readonly int _age;
public Person(string firstName, string surname, int age)
{
var fault = new SocketException(errorCode: 10013);
var policy = MonkeyPolicy.InjectFault(
fault,
injectionRate: 0.05,
enabled: () => isEnabled()
);

Getting the following error when running promtrail:

./promtail_darwin_amd64 -config.file=promtail.yml

level=error ts=2019-10-09T20:07:54.577597Z caller=main.go:51 msg="error creating promtail" error="failed to make file target manager: invalid json stage config: JMES expression is required"

My log file:

{"@t":"2019-10-09T17:59:46.4148580Z","@mt":"Hello, world!","@l":"Debug"}
[HtmlTargetElement("div")]
public class VisibilityTagHelper : TagHelper
{
public bool IsVisible { get; set; } = true;
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (!IsVisible)
output.SuppressOutput();