Skip to content

Instantly share code, notes, and snippets.

set status

Chris Missal ChrisMissal

set status
Block or report user

Report or block ChrisMissal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ChrisMissal /
Last active Aug 30, 2019
Example of Partial DbContext and interface for mocking/testing.


The file WorkifyEntities.Context.cs is what EF generates for us, or in EF Core, you can create yourself on top of the base class.

The Entities.cs file, we create our own partial class, and assign an interface. From here, we will register our own interface while the instance will be the DbContext.


Just inject the interface and use it. You will have to add properties and methods to the interface to match the DbContext.

View FailingTest.cs
public class Test
public class Name
public string Text { get; set; }
public abstract class Widget
public abstract Name Name { get; }
View ConsistentInterval.cs
public class ConsistentInterval : IDisposable
private readonly TimeSpan delay;
private readonly CancellationToken cancellationToken;
private readonly DateTimeOffset startTime;
public ConsistentInterval(TimeSpan delay, CancellationToken cancellationToken)
this.delay = delay;
this.cancellationToken = cancellationToken;
ChrisMissal /
Last active Aug 29, 2015
The Once & Future Web: Mat Marquis

I love this quote by Mat Marquis from TXJS 2015:

We, as an industry, have nearly decided that we are all doing a really, really good job as long as we don't count the instances where we're doing a really, really bad job.


ChrisMissal / clitests.cs
Last active Aug 29, 2015
CLI Code Spike – Rethinking how I interact with the command line via C# a little bit. I have some spike code in which all these tests pass. Thoughts?
View clitests.cs
public class CommandResolutionTests
public void should_resolve_text_to_command()
public void should_call_command_hello()
"samplecommand hello".Called<SampleCommand>()
View DumbSample.sql
begin transaction
create table DumbSample (
Expired bit default 0,
Name varchar(max)
insert into DumbSample (Expired, Name) values (0, 'Milk');
ChrisMissal / ImplicitCausingNullRef.cs
Created Apr 10, 2014
Implicit operator causing sneaky NullReferenceException
View ImplicitCausingNullRef.cs
void Main()
var order = new Order
Instructions = SpecialInstructions.LeaveAtDoor,
var thing = new Thing
Instructions = order.Instructions,
ChrisMissal / ApiController.cs
Last active Dec 29, 2015
URLs as JSON to be used on the client
View ApiController.cs
using System.Linq;
using System.Web.Mvc;
using Construction.Core.Features.QuickSearch;
using Construction.Core;
using Construction.Core.Extensions;
using Core.Helpers;
using Newtonsoft.Json.Linq;
public class ApiController : BaseController
ChrisMissal / screencapture.ps1
Created Sep 19, 2013
How can I do a screen capture in windows powershell?
View screencapture.ps1
function screenshot([Drawing.Rectangle]$bounds, $path) {
$bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
ChrisMissal / find_references.sql
Created Sep 19, 2013
Find all columns that have foreign keys referencing another table.
View find_references.sql
select as TableWithForeignKey, fk.constraint_column_id as FK_PartNo , as ForeignKeyColumn
from sys.foreign_key_columns as fk
inner join sys.tables as t on fk.parent_object_id = t.object_id
inner join sys.columns as c on fk.parent_object_id = c.object_id and fk.parent_column_id = c.column_id
where fk.referenced_object_id = (select object_id from sys.tables where name = 'tablename')
order by TableWithForeignKey, FK_PartNo
You can’t perform that action at this time.