Skip to content

Instantly share code, notes, and snippets.

View ploeh's full-sized avatar

Mark Seemann ploeh

View GitHub Profile
@ploeh
ploeh / gist:4f873315fc556f7672f1
Created May 15, 2015 18:37
F# readability test.
let nerdCapsToKebabCase (text : string) =
let charToString index c =
let s = c.ToString().ToLower()
match index, Char.IsUpper c with
| 0, _ -> s
| _, true -> "-" + s
| _ -> s
text |> Seq.mapi charToString |> String.concat ""
@ploeh
ploeh / gist:9702672
Created March 22, 2014 07:30
ASP.NET Web API 2 ApiController AutoFixture Customization
type ApiControllerCustomization() =
let controllerSpecification =
{ new IRequestSpecification with
member this.IsSatisfiedBy request =
match request with
| :? Type as t when typeof<ApiController>.IsAssignableFrom t ->
true
| _ -> false }
interface ICustomization with
public class ImmutableXYZ {
public ImmutableXYZ() : this("", 0, -1) {
}
private ImmutableXYZ(string abc, int def, int haha)
{
this.abc = abc;
this.def = def;
this.haha = haha;
}
@ploeh
ploeh / gist:1185766
Created September 1, 2011 09:08
Configuring ordered named sequences in Unity
container.RegisterType<IMeal, Meal>(
new InjectionConstructor(
new ResolvedArrayParameter<ICourse>(
new ResolvedParameter<ICourse>("entrée"),
new ResolvedParameter<ICourse>("mainCourse"),
new ResolvedParameter<ICourse>("dessert"))));
@ploeh
ploeh / InputParseCommandTest.cs
Created August 22, 2011 13:40
Inline auto-data
[Theory]
[InlineAutoHostData(null)]
[InlineAutoHostData("")]
[InlineAutoHostData]
public void ExecuteUnknownInputCorrectlyInvokesOnUnknown(string unknownInput, Action dummyOnExit)
{
var verified = false;
var sut = new InputParseCommand(dummyOnExit, i => verified = i == unknownInput);
sut.Execute(unknownInput);
Assert.True(verified);