Skip to content

Instantly share code, notes, and snippets.

View dealproc's full-sized avatar

Richard Bennett dealproc

View GitHub Profile
@dealproc
dealproc / ApiTestBase.cs
Created February 12, 2016 13:53
base test class for nancy
using FakeItEasy;
using Nancy.Owin;
using Nancy.Testing;
using Nancy.TinyIoc;
using Owin;
using System;
using System.Collections.Generic;
@dealproc
dealproc / TestServerFixture.cs
Created January 25, 2016 20:08
Sample Fixture for an owin test server
using Microsoft.Owin.Testing;
using System;
using System.Linq;
using System.Net.Http;
using Xunit;
namespace {Your Project}.Tests.Fixtures {
[CollectionDefinition("Test Server")]
@dealproc
dealproc / TaskExtensions.cs
Last active January 12, 2016 19:07
Retry logic for tasks
namespace YourProduct
{
/// <summary>
/// Task retry logic
/// </summary>
public static class TaskHelper
{
/// <summary>
/// Returns a task which retries the task returned by the specified task provider.
/// </summary>
@dealproc
dealproc / map.cshtml
Created January 11, 2016 14:56
_paws map.cshtml
<style type="text/css">
#legend {
background-color: #3C5A76;
border: 2px solid #cccc;
color: #EEEEEE;
font-weight: bold;
position: absolute;
right: 50px;
top: 50px;
padding: 15px;
@dealproc
dealproc / WorkerRole.cs
Created January 7, 2016 09:49
Azure Worker Role for hosting an Owin application
namespace Your.Product.Namespace
{
public class WorkerRole : RoleEntryPoint, IDisposable
{
readonly TaskCompletionSource<bool> _endRole = new TaskCompletionSource<bool>();
readonly ManualResetEvent _runCompleteEvent = new ManualResetEvent(false);
IDisposable _app;
bool _disposed = false;
~WorkerRole()
@dealproc
dealproc / applicationsettingshelper.cs
Last active December 14, 2015 15:29
app settings helper
public class ApplicationSettingsHelper : IApplicationSettingsHelper
{
readonly IApplicationSettingRepository _applicationSettingRepository;
/// <summary>
/// Default constructor
/// </summary>
public ApplicationSettingsHelper(IApplicationSettingRepository applicationSettingsRepository)
{
_applicationSettingRepository = applicationSettingsRepository;
@dealproc
dealproc / install.ps1
Created October 20, 2015 20:09
drey.install.ps1
param (
$installPath,
$toolsPath,
$package,
$project
)
# Find Debug configuration and set debugger settings.
Write-Host "`tSetting startup information in Debug configuration"
@dealproc
dealproc / TestingDelegatingHandler.cs
Created September 2, 2015 12:29
Testing Delegating Handler
/// <summary>
/// From: http://blogs.msmvps.com/theproblemsolver/2013/05/20/unit-testing-code-depending-on-the-asp-net-webapi-httpclient/
/// </summary>
/// <typeparam name="T"></typeparam>
public class TestingDelegatingHandler<T> : DelegatingHandler {
private Func<HttpRequestMessage, HttpResponseMessage> _httpResponseMessageFunc;
public TestingDelegatingHandler(T value) : this(HttpStatusCode.OK, value) { }
public TestingDelegatingHandler(HttpStatusCode statusCode) : this(statusCode, default(T)) { }
public TestingDelegatingHandler(HttpStatusCode statusCode, T value) {
@dealproc
dealproc / something.ps1
Last active August 29, 2015 14:25
Gist on how i setup teamcity, based on octopus deploy's script.
# These are project build parameters in TeamCity
# Depending on the branch, we will use different major/minor versions
$majorMinorVersionMaster = "%system.MajorMinorVersion.Master%"
#$majorMinorVersionMaster = "1.9.0"
# TeamCity's auto-incrementing build counter; ensures each build is unique
$buildCounter = "%build.counter%"
#$buildCounter = "999"
# This gets the name of the current Git branch.
@dealproc
dealproc / TokenManager.cs
Created July 5, 2015 05:13
C# OAuth Token Manager
public class TokenManager {
static readonly ILog _log = LogProvider.For<TokenManager>();
string _clientId = "{your client id}";
string _secret = "{your secret}";
string _scopes = "{claims} offline_access"; // needs the offline_access to get the refresh token.
CloudConnectConfiguration _configuration;
Task _workerLoop;
CancellationTokenSource _cts;