Skip to content

Instantly share code, notes, and snippets.

View forki's full-sized avatar

Steffen Forkmann forki

View GitHub Profile
@forki
forki / NaturalSpec.nuspec.xml
Created February 18, 2011 11:44
.nuspec file for NaturalSpec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<description>@description@</description>
<id>@project@</id>
<version>@build.number@</version>
<authors>@authors@</authors>
<owners>@authors@</owners>
<language>en-US</language>
<summary>@summary@</summary>
@forki
forki / gist:833572
Created February 18, 2011 11:47
Build und push nuget package
Target "BuildNuGet" (fun _ ->
let nugetDocsDir = nugetDir @@ "docs/"
let nugetLibDir = nugetDir @@ "lib/"
let nugetContentDir = nugetDir @@ "Content/"
XCopy docsDir nugetDocsDir
XCopy buildDir nugetLibDir
XCopy nugetContentSourceDir nugetContentDir
NuGet (fun p ->
@forki
forki / gist:833575
Created February 18, 2011 11:48
MSpec test
Target "Test" (fun () ->
!+ (testDir + @"\*Tests.dll")
|> Scan
|> MSpec (fun p ->
{p with
ExcludeTags = ["Selenium"]
HtmlOutputDir = testOutputDir})
)
@forki
forki / gist:835226
Created February 19, 2011 18:01
brainstorming for parameterized MSpecs
public class Math
{
public static int Fac(int x)
{
if (x <= 1)
return 1;
return Fac(x - 1)*x;
}
}
@forki
forki / gist:836131
Created February 20, 2011 17:32
Automatic AutoMapper tests
public abstract class when_mapping_to_another_type_and_back<T, S>
{
protected static T Model;
protected static T Mapped;
Because of = () => Mapped = Model.MapTo<S>().MapTo<T>();
protected static void VerifyAllProperties()
{
foreach (var property in typeof (T).GetProperties())
@forki
forki / gist:837312
Created February 21, 2011 16:34
First trial for FluentSelenium in MSpec
[Subject(typeof (AcqRequestHeader))]
public class When_creating_call_order_with_frame_contract : when_logged_in
{
Because of =
() => FluentSelenium<AcqRequestHeaderViewModel>()
.GoToUrl("AcqRequestHeader/Create")
.SelectValueFrom(x => x.Record_Type, "Abrufauftrag")
.TypeTextInFor(x => x.Frame_Contract_No, "12345");
It should_not_display_an_error_message =
@forki
forki / gist:843770
Created February 25, 2011 13:22
Behavior configuration sample for Machine.Fakes
public class Given_the_current_day_is_monday_when_identifying_my_mood : WithSubject<MoodIdentifier>
{
static string _mood;
Establish context = () => With(new CurrentTime(new DateTime(2011, 2, 14)));
Because of = () => _mood = Subject.IdentifyMood();
It should_be_pretty_bad = () => _mood.ShouldEqual("Pretty bad");
}
@forki
forki / gist:848791
Created March 1, 2011 07:57
FSharpRecordExtensions to allow (mutable) With-Syntax in C#
public static class FSharpRecordExtensions
{
public static string GetPropertyName<T, TProperty>(this Expression<Func<T, TProperty>> expression)
{
return ((MemberExpression) expression.Body).Member.Name;
}
public static Tuple<T, FieldInfo> Set<T, S>(this T target, Expression<Func<T, S>> expression)
{
var propertyName = expression.GetPropertyName();
@forki
forki / gist:879219
Created March 21, 2011 09:33
Mechanical transformation from out parameters to tuples.
public class SdkClass
{
public int GetInfo(string param1, out string outParam)
{
// ...
var errorCode = 1;
outParam = "MyInfo";
return errorCode;
}
}
@forki
forki / gist:883148
Created March 23, 2011 14:16
Dealing with infinity
// you can do this even with BigInteger
static IEnumerable<long> AllNumbers()
{
var x = 0;
while (true)
yield return x++;
}
static IEnumerable<long> AllEvenNumbers()
{