Skip to content

Instantly share code, notes, and snippets.

[Subject(typeof (FluSectionResultGenerator))]
public class when_applicant_provides_information_indicating_flu_susceptibility : given_a_generator_context
{
Because of = () => Generator.Run(new[] {new Question("Do you have issues?") {Answer = true},});
It should_reflect_susceptibility_to_the_flu = () => FileSystemMock.Verify(x => x.Read( "a/b/c/susceptable.txt"));
}
[Subject(typeof (FluSectionResultGenerator))]
public class when_applicant_provides_no_information_indicating_flu_susceptibility : given_a_generator_context
@derekgreer
derekgreer / custom_assertion_test.cs
Created June 11, 2011 15:56
Custom Assertion Test
public class when_asserting_unsorted_comments_are_sorted_in_descending_order
{
static Exception _exception;
static List<Comment> _unsortedComments;
Establish context = () =>
{
_unsortedComments = new List<Comment>
{
new Comment("comment 1", DateTime.MinValue.AddDays(1)),
@derekgreer
derekgreer / gist:1065000
Created July 5, 2011 14:59
rake snippet
sh "#{WEB_PACKAGE_LOCATION}/#{PROJECT_NAME}.deploy.cmd /M:localhost /Y \"-skip:objectName=dirPath,skipAction=Delete,absolutePath=logs\""
@derekgreer
derekgreer / Monarchy.cs
Created July 22, 2011 22:48
Monarchy Refactored
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Monarchy {
public class ObjectFactory {
static readonly IDictionary<Type, Func<object>> Container = new Dictionary<Type, Func<object>>();
public T Get<T>() {
@derekgreer
derekgreer / MonarchySpecs.cs
Created July 22, 2011 22:49
Monarchy Refactored Specs
using Machine.Specifications;
namespace Monarchy.Specs
{
[Subject(typeof(ObjectFactory))]
public class when_retrieving_a_type_with_registered_dependency_factory
{
static TestService _instance;
static ObjectFactory _factory;
@derekgreer
derekgreer / findDeadProjects.sh
Created November 1, 2011 23:39
Bash script to find dead projects
#!/bin/bash
declare -a SOLUTIONS=$(find . -name "*.sln")
declare -a PROJECTS=$(find . -name "*.csproj")
for PROJECT in ${PROJECTS[*]}
do
PROJECT_NAME=$(basename $PROJECT)
USED=0
@derekgreer
derekgreer / rake_which
Created December 1, 2011 17:10
Rake which method
def which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|
sep = File::ALT_SEPARATOR || File::SEPARATOR
exe = "#{path}#{sep}#{cmd}#{ext}"
return exe if File.executable? exe
}
end
return nil
@derekgreer
derekgreer / gist:1981240
Created March 5, 2012 21:33
Assertion First Example
[Integration]
[Subject(typeof (RabbitBus))]
public class when_subscribing_to_receive_a_message_type_without_an_explicit_subscription_registration
{
Establish context;
Because of;
It should_subscribe_with_the_default_registration_conventions = () => _actualMessage.ShouldEqual(_expectedMessage);
}
@derekgreer
derekgreer / git-commit-often.bash
Last active August 29, 2015 14:04
git-commit-often.bash
#!/bin/bash
while (( 1 ))
do
BRANCH=$(git rev-parse --abbrev-ref HEAD)
CHANGES=$(git status --porcelain)
if [[ "${CHANGES}" != "" && "${BRANCH}" != "master" ]]
then
@derekgreer
derekgreer / gist:1efd7d4e9d206cb2862b
Created September 10, 2014 16:08
NodaDb: A NoSql datastore
public class NodaDb<TKey, TValue> : Dictionary<TKey, TValue>
{
}