Skip to content

Instantly share code, notes, and snippets.

namespace Kata
{
using System.Collections.Generic;
using System.Linq;
using Xunit;
public interface ICheckout
{
void Scan(string item);
@mat-mcloughlin
mat-mcloughlin / reservation-pattern
Created July 17, 2014 10:38
Attempt at reservation pattern
public class FooReserver
{
private readonly int reserveFor;
public static List<string> ReservedFoos = new List<string>();
public FooReserver(int reserveFor)
{
this.reserveFor = reserveFor;
}
public class GameId : TypedGuid
{
}
public class TypedGuid
{
protected Guid Value { get; set; }
public static implicit operator Guid(TypedGuid typedGuid)
{
var decision = "Dave".DecidesTo<InviteToLobby>();
decision.ProvidedDataIs("something");
decision.NewKnowledgeIs<InvitedToLobby>((e) => e.Something.ShouldBe("test"));
decision.IsAvailableWhen(() => new TestTopicInValidState());
decision.IsntAvailableWhen<ExpectedException>(() => new TestTopicInInvalidState());
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global define, $, brackets, window */
define(function (require, exports, module) {
'use strict';
var CodeHintManager = brackets.getModule('editor/CodeHintManager'),
EditorManager = brackets.getModule("editor/EditorManager"),
Helpers = require('modules/helpers'),
Omnisharp = require('modules/omnisharp');
@mat-mcloughlin
mat-mcloughlin / init.el
Last active August 29, 2015 14:09
init.el
(require 'package)
(add-to-list 'package-archives'("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
(require 'smex) ; Not needed if you use package.el
(smex-initialize) ; Can be omitted. This might cause a (minimal) delay
; when Smex is auto-initialized on its first run.
(global-set-key (kbd "M-x") 'smex)
(require 'twittering-mode)
@mat-mcloughlin
mat-mcloughlin / Sample.cs
Last active August 29, 2015 14:13
Sample
public class SubmitOrder
{
public SubmitOrder(int orderId)
{
OrderId = orderId;
}
public int OrderId { get; private set; }
}
@mat-mcloughlin
mat-mcloughlin / abstract
Last active August 29, 2015 14:14
.NET sans Microsoft
It used to be that if you wanted to write .NET code you would be completely reliant on Microsoft for their tools, frameworks and even their operating system. Now things are changing. The .NET open source community has grown in size, and with it, so have your options for frameworks and libraries. Microsoft have even annouced that they are building a cross platform CLR, so you are no longer reliant on Windows. The release of Roslyn and its rich code analysis API's is bringing with it a new wave of lightweight cross platfrom editors that can replace Visual Studio.
In this talk I will discuss some of these technologies, tools and libraries, and demonstrate their viability to show you that there is a new way of developing in the .NET world.
@mat-mcloughlin
mat-mcloughlin / Guard.cs
Last active August 29, 2015 14:16
guard.cs
namespace Foo
{
using System;
internal static class Guard
{
internal static void EnsureNotNull(object argument, string argumentName)
{
if (argument == null)
{
@mat-mcloughlin
mat-mcloughlin / rename.cs
Created May 30, 2015 16:21
Roslyn Rename
public RosylnController()
{
_workspace = new AdhocWorkspace();
_project = _workspace.AddProject("AdhocProject", LanguageNames.CSharp);
}
[Route("rename")]
public async Task<string> Post(string buffer, int line, int column, string newName)
{
var document = _project.AddDocument("AdhocDocument", SourceText.From(buffer));