Skip to content

Instantly share code, notes, and snippets.

View nickhodge's full-sized avatar

Nick Hodge nickhodge

View GitHub Profile
@nickhodge
nickhodge / JsonClient.cs
Created September 9, 2018 03:14
JsonClient with Simple, Backoff and CircuitBreaker patterns. Only GET POST PUT. Serialisation included
public enum CircuitBreakerState {
Unknown = 0,
Closed = 1,
Open = 2,
HalfOpen = 3,
}
public class JsonClient: IDisposable
{
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Newtonsoft.Json;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Xunit;
@nickhodge
nickhodge / TestWebAppFactory.cs
Last active September 5, 2018 07:07
TestWebAppFactory.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
// ref: https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-2.1#aspnet-core-integration-tests
namespace xxx
{
public class TestStartup
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace xxx
{
public static class ConfigureServicesHandlers
{
public static void AddCustomisedMVC(this IServiceCollection services)
{
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace xxx
{
public static class ConfigureAppHandlers
{
public static void AddTransportSecurity(this IApplicationBuilder app)
using System;
using System.Linq;
namespace xxx
{
public interface IResult
{
bool WasSuccessful { get; }
bool WasSuccess { get; }
string[] Errors { get; }
public static string AsQueryString(this Dictionary<string, string> parameters)
{
if (!parameters.Any())
return "";
var builder = new StringBuilder("?");
var separator = "";
foreach (var kvp in parameters.Where(kvp => kvp.Value != null))
{
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace xxx
{
public class Startup
{
namespace Unosquare.Labs.EmbedIO.Modules
{
using Constants;
using EmbedIO;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Swan;
import { Builder, Capabilities, By, until, ThenableWebDriver } from 'selenium-webdriver';
import { expect, should } from 'chai';
should(); // this inits the chai should above up. for some reason
import { chaiWebDriver } from 'chai-webdriver';
import { spawn } from 'cross-spawn-async';
import 'mocha';
let iisPath = "C:\\Program Files (x86)\\IIS Express\\iisexpress.exe";