Skip to content

Instantly share code, notes, and snippets.

View jamesmh's full-sized avatar
💭
👨‍💻

James Hickey jamesmh

💭
👨‍💻
View GitHub Profile
public class DummyDatabaseTest : DbTest
{
[Fact]
void when_the_thing_is_tested_then_we_are_happy()
{
Session.Query<User>()
.Any(x => x.IsActive)
.ShouldBeTrue();
}
}
@jamesmh
jamesmh / Startup.cs
Last active December 15, 2019 03:36
Bind Coravel To .NET Framework (unsupported)
using Coravel;
using Coravel.Scheduling.Schedule.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Owin;
using Owin;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@jamesmh
jamesmh / Query.cs
Last active August 15, 2018 16:44
ADO Query Class
public class Query
{
private readonly string _connectionString;
public Query(string connectionString)
{
this._connectionString = connectionString;
}
public async Task<T> UsingConnectionAsync<T>(Func<SqlConnection, Task<T>> func)
@jamesmh
jamesmh / BindConstructorParametersAsProperties.ts
Created March 3, 2017 16:36
TypeScript decorator to bind constructor arguments as object properties with the same names / keys as the parameter names.
export default (constructor: any) => {
const functionString = constructor.toString();
const params = GetArgumentNames(functionString);
const newConstructor: any = function (...args) {
const newObj = new constructor(args);
params.map((param, index) => newObj[param] = args[index]);
return newObj;
}