Skip to content

Instantly share code, notes, and snippets.

View marcusoftnet's full-sized avatar

Marcus Hammarberg marcusoftnet

View GitHub Profile
[Given(@"the following features in the database:")]
public void GivenTheFollowingFeaturesInTheDatabase(Table table)
{
// 1. Create a list of features => drive forth the feature class
var features = table.CreateSet<Feature>().ToList();
// 2. Create an substitute that returns that list
var dbWrapperSubsitute = Substitute.For<IFeatureDBWrapper>();
dbWrapperSubsitute.AllNotDone().Returns(features);
@marcusoftnet
marcusoftnet / CaptureScreenShotsOnFailure
Created March 25, 2011 14:41
Here i'm using MvcContrib.Watin testhelper together with the SpecFlow hook for AfterScenario to capture a screen shot on each failing tests, naming the
using Specs.EndToEnd.Helpers;
using TechTalk.SpecFlow;
namespace Specs.EndToEnd
{
[Binding]
public class SpecFlowHooks
{
[AfterScenario]
@marcusoftnet
marcusoftnet / gist:941065
Created April 25, 2011 19:45
Dead-simple usage
public class ActivityDbEntity
{
public string Heading { get; set; }
public string NumberOfHours { get; set; }
public string Date { get; set; }
public string Coach { get; set; }
public string Customer { get; set; }
}
@marcusoftnet
marcusoftnet / gist:964983
Created May 10, 2011 17:49
Get Property substituting
// This is the interface i want to Subsitute
public interface ICustomerRepository
{
IQueryable<Customer> All { get; } // This property
IQueryable<Customer> AllIncluding(params Expression<Func<Customer, object>>[] includeProperties);
Customer Find(int id);
void InsertOrUpdate(Customer customer);
void Delete(int id);
void Save();
}
@marcusoftnet
marcusoftnet / TinyIoCAndWCF
Created July 12, 2011 18:33
An implementation to get IoC support for WCF Services using TinyIoC (shamelessly stealing from Jimmy Bogard :))
using System;
using System.Collections.ObjectModel;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
/*
* This is an TinyIoC implemention of the example in the excellent blog post by Jimmy Boggard
@marcusoftnet
marcusoftnet / gist:1159487
Created August 20, 2011 18:49
Trying out Razor and Nancy
@IList<Person> model = (IList<Person>)Model;
<!DOCTYPE HTML />
<html>
<head></head>
<body>
<ul>
@foreach (Person p in Model)
{
<li>@p.name</li>
@marcusoftnet
marcusoftnet / gist:1177936
Created August 29, 2011 07:19
Git push problem
$ git push origin master
Counting objects: 106, done.
Compressing objects: 100% (103/103), done.
Received disconnect from 207.97.227.239: 2: Corrupted MAC on input.
fatal: sha1 file '<stdout>' write error: Invalid argument
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '[email protected]:marcushammarberg/SpecFlow.Ass
ist.Dynamic.git'
@marcusoftnet
marcusoftnet / gist:1195044
Created September 5, 2011 13:57
SpecFlow ... using method binders... or what we should call them
[Binding]
public class DynamicStepArgumentTransformations
{
[StepArgumentTransformation]
public IEnumerable<object> TransformToEnumerable(Table table)
{
return table.CreateDynamicSet();
}
@marcusoftnet
marcusoftnet / gist:1202853
Created September 8, 2011 07:32
StepArgumentTransformation with generics
[StepArgumentTransformation]
public T CreateUser<T>(Table table) where T : new()
{
// magic happens here stuff
// or this line
// any case a new T gets created
return table.CreateInstance<T>();
}
@marcusoftnet
marcusoftnet / gist:1212018
Created September 12, 2011 18:35
Testing Nancy modules
using System.Collections.Generic;
using Nancy;
using Nancy.Bootstrapper;
using NSubstitute;
using NUnit.Framework;
namespace UnitTests
{
[TestFixture]
public class AbbeQuotesModuleTests