Skip to content

Commit

Permalink
Make it possible to use fuchu as a single file via paket (#61)
Browse files Browse the repository at this point in the history
* Folding Assertions into Fuchu.fs

* Documentation about usage
  • Loading branch information
wallymathieu authored Oct 24, 2018
1 parent f3c9e44 commit a67f9fe
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
36 changes: 0 additions & 36 deletions Fuchu/Assertions.fs

This file was deleted.

36 changes: 35 additions & 1 deletion Fuchu/Fuchu.fs
Original file line number Diff line number Diff line change
Expand Up @@ -592,4 +592,38 @@ type Test with

/// Fail this test
static member Fail(reason: string, [<ParamArray>] args: obj[]) =
failtest (String.Format(reason, args)) |> ignore
failtest (String.Format(reason, args)) |> ignore


type Assert =

static member NotEqual(msg, negative_case, actual) =
if negative_case = actual
then failtestf "%s\nExpected: %A\nnot to equal Actual: %A" msg negative_case actual

static member Equal(msg, expected, actual) =
if expected <> actual
then failtestf "%s\nExpected: %A\nActual: %A" msg expected actual

static member None(msg, value) =
match value with
| Some x -> failtestf "%s\nExpected None, Actual: Some (%A)" msg x
| _ -> ()

static member NotNull<'a when 'a : null>(msg, actual: 'a) =
match box actual with
| null -> failtestf "%s\nShould not have been null" msg
| _ -> ()

static member Raise(msg, ex: Type, f) =
try
f()
failtestf "%s\nExpected exception '%s' but no exception was raised" msg ex.FullName
with e ->
if e.GetType() <> ex
then failtestf "%s\nExpected exception '%s' but raised:\n%A" msg ex.FullName e

static member StringContains(msg, expectedSubString, actual: string) =
if not (actual.Contains expectedSubString)
then failtestf "%s\nExpected string containing: %s\nActual: %s" msg expectedSubString actual

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ much cheaper.

Binaries are available on [NuGet](http://nuget.org/packages?q=Fuchu).

## Source ##

Add the following line to your paket.dependencies file

github mausch/Fuchu Fuchu/Fuchu.fs

## Writing tests ##

Here's the simplest test possible:
Expand Down

0 comments on commit a67f9fe

Please sign in to comment.