Skip to content

Instantly share code, notes, and snippets.

View moodmosaic's full-sized avatar

Nikos Baxevanis moodmosaic

View GitHub Profile
@moodmosaic
moodmosaic / gist:7fba17beae7cee92581a
Last active August 29, 2015 14:16
Feedback, related to an answer on Stack Overflow at: http://stackoverflow.com/a/28798955/467754
type OddlySpelledWords =
static member String() =
["zZ"; "oO0Ò"; "eEê"]
|> List.map Gen.elements
|> Gen.sequence
|> Gen.map (List.map string >> List.reduce (+))
|> Arb.fromGen
[<Property(Arbitrary = [| typeof<OddlySpelledWords> |])>]
let ``Generate oddly spelled words`` s =
@moodmosaic
moodmosaic / DiamondProperties.fs
Created February 24, 2015 08:12
Exude applied to post titled: Property Based Testing without a Property Based Testing framework
let verify = Swensen.Unquote.Assertions.test
[<FirstClassTests>]
let ``Diamond is as wide as it's high`` () =
seq {'A' .. 'Z'}
|> Seq.map (fun letter -> TestCase (fun () ->
let actual = Diamond.make letter
let rows = split actual
let expected = rows.Length
@moodmosaic
moodmosaic / ReturnValueMustNotBeNullAssertionScenarios.fs
Created November 5, 2014 21:45
ReturnValueMustNotBeNullAssertionScenarios
namespace ReturnValueMustNotBeNullAssertionScenarios
open FsCheck
open Ploeh.AutoFixture.Idioms.FsCheck
open Ploeh.AutoFixture.Kernel
open Ploeh.AutoFixture.Xunit
open System
open Xunit.Extensions
type Generators =
@moodmosaic
moodmosaic / 1-DomainModel.fs.diff
Last active August 29, 2015 14:04
In-memory Drain abstractions applied to A Functional Architecture with F#.
diff --git a/BookingApi/DomainModel.fs b/BookingApi/DomainModel.fs
index 4a4260f..c2079cf 100644
--- a/BookingApi/DomainModel.fs
+++ b/BookingApi/DomainModel.fs
@@ -7,6 +7,23 @@ type Period =
| Month of int * int
| Day of int * int * int
+[<AutoOpen>]
+module Drain =
public interface IInterface
{
object MakeIt(object obj);
}
public abstract class AbstractTypeWithNonDefaultConstructor<T>
{
private readonly T property;
protected AbstractTypeWithNonDefaultConstructor(T value)
@moodmosaic
moodmosaic / TestDsl.fs
Last active August 29, 2015 14:01
F# port of @ploeh's answer at http://stackoverflow.com/a/20723447/467754 for ASP.NET Web API 2.
// F# port of @ploeh's answer at http://stackoverflow.com/a/20723447/467754 for ASP.NET Web API 2.
type WebApiCustomization() =
interface ICustomization with
member this.Customize fixture =
fixture.Customize<HttpConfiguration>(fun c ->
c.OmitAutoProperties() :> ISpecimenBuilder)
fixture.Customize<HttpRequestMessage>(fun c ->
c.Do(fun (x : HttpRequestMessage) ->
x.Properties.[HttpPropertyKeys.HttpConfigurationKey] <-
module Scenarios
open Ploeh.AutoFixture
open Ploeh.AutoFixture.Kernel
open Ploeh.Albedo
open Ploeh.Albedo.Refraction
open System
type TextEndsWithConvention(value, found) =
inherit ReflectionVisitor<bool>()
@moodmosaic
moodmosaic / Scenarios.fs
Last active August 29, 2015 14:00
mountebank stubs with F#
open FSharp.Data
open System
open System.Net
open Xunit
let verify = Swensen.Unquote.Assertions.test
[<Fact>]
[<UseImposterStub(
"192.168.1.4",
@moodmosaic
moodmosaic / runner.html
Last active August 29, 2015 14:00
A small sample of a Jasmine custom matcher that internally parses expressions into an AST.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Custom matchers for Expressions</title>
<!-- $ bower install jasmine && npm install jsep -->
<link href="bower_components/jasmine/lib/jasmine-core/jasmine.css" rel="stylesheet" />
<script src="bower_components/jasmine/lib/jasmine-core/jasmine.js"></script>
@moodmosaic
moodmosaic / Scenarios.fs
Last active August 29, 2015 14:00
mountebank mocks with F#
module Mountebank.Scenarios
// PM> Install-Package xunit
// PM> Install-Package Unquote
open System
open System.Net.Mail
open Xunit
let verify = Swensen.Unquote.Assertions.test