Skip to content

Instantly share code, notes, and snippets.

View JakeGinnivan's full-sized avatar
:shipit:

Jake Ginnivan JakeGinnivan

:shipit:
View GitHub Profile
@JakeGinnivan
JakeGinnivan / RefactoringToExamplesInBddfy.cs
Last active August 29, 2015 14:00
Refactoring data driven nUnit test to BDDfy example test
// Start with a nUnit Test case
[TestCase(Foo.Bar, Foo.Baz, Foo.Qux)]
[TestCase(Foo.Baz, Foo.Qux, Foo.Bar)]
public void MyTest(Foo givenArg, Foo whenArg, Foo thenArg)
{
this.Given(_ => GivenSomething(givenArg))
.When(_ => WhenSomething(whenArg))
.Then(_ => ThenSomething(thenArg))
.BDDfy();
}
Scenario: Fluent can be used with examples
Given method taking <example int>
Given method taking <prop 1>
Given a different method with random arg 2
Given a different method with <prop 2>
When method using <example string>
Then all is good
Examples:
public class ReflectiveExamples
{
public int Start { get; set; }
public int Eat { get; set; }
public int Left { get; set; }
//Scenario Outline: eating
// Given there are <start> cucumbers
// When I eat <eat> cucumbers
// Then I should have <left> cucumbers
@JakeGinnivan
JakeGinnivan / FluentExamples.cs
Created April 1, 2014 10:41
BDDfy Fluent Examples Ideas
//https://github.com/cucumber/cucumber/wiki/Scenario-Outlines
//Scenario: eat 5 out of 20
// Given there are 20 cucumbers
// When I eat 5 cucumbers
// Then I should have 15 cucumbers
//Scenario Outline: eating
// Given there are <start> cucumbers
// When I eat <eat> cucumbers
// Then I should have <left> cucumbers
@JakeGinnivan
JakeGinnivan / Linqpad.cs
Created March 17, 2014 08:23
Lambda shiz
void Main()
{
GetExpression().Compile()(new Foo { Bar = new Bar { Abc = "A" }}).Dump();
GetExpression().Compile()(new Foo { Bar = new Bar { Abc = "B" }}).Dump();
}
Expression<Func<Foo, bool>> GetExpression()
{
// Method takes Foo and uses an expression to first retrieve Bar
@JakeGinnivan
JakeGinnivan / gist:9247018
Created February 27, 2014 09:29
VSTest.Console
Extensions/*
ActivateApplication.exe
EntityFramework.dll
Microsoft.TeamFoundation.TestPlatform.Client.dll
Microsoft.TestTools.Cpp.targets
Microsoft.VisualStudio.MSTest.TestWindow.dll
Microsoft.VisualStudio.TestPlatform.BuildTasks.dll
Microsoft.VisualStudio.TestPlatform.Client.dll
Microsoft.VisualStudio.TestPlatform.Common.dll
Microsoft.VisualStudio.TestPlatform.Core.dll
@JakeGinnivan
JakeGinnivan / InProcessAutomation.cs
Created January 18, 2014 09:23
Demonstrates how to host a WPF application in your test then verify visual things.
public static class TestHost
{
Application _app;
Thread _appThread;
public static void Start()
{
_appThread = new Thread(StartDispatcher);
}
@JakeGinnivan
JakeGinnivan / xUnit to nUnit.cs
Created January 16, 2014 17:40
Script to help convert between nUnit and xUnit
class Settings
{
public static string SolutionPath = @"C:\_code\foo\src";
}
/*
Helper classes (to replace certain things in nUnit)
// Replaces implicit attribute (kinda, instead only runs when debugger is attached)
public class RunnableInDebugOnlyAttribute : FactAttribute
SyncCtx/IsThreadPool/ThreadId: System.Windows.Threading.DispatcherSynchronizationContext/False/8
SyncCtx/IsThreadPool/ThreadId: System.Windows.Threading.DispatcherSynchronizationContext/True/10
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="MainWindow" Title="WPF3D" Width="534"
Height="254">
<Grid>
Plugin works well, except the first element, I am getting a space inserted before the window, and also I can't add/remove the namespace so the formatting is screwed.