Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate .NET Project to F# #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions FSharp/Calculator/Calc.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Calculator

let sum a b = a + b

let subtract a b = a - b

let multiply a b = a * b

let divide a b = a / b
28 changes: 28 additions & 0 deletions FSharp/CalculatorTest/TestCalculator.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module TestCalculator

open NUnit.Framework
open FsUnit
open Calculator

[<TestFixture>]
type TestCalculator() =

[<OneTimeSetUp>]
member this.Setup() = printfn "Starting Calculator tests"

[<OneTimeTearDown>]
member this.TearDown() = printfn "Calculator tests are finished"

[<Test>]
[<Category("SumTests")>]
member this.OneCanSumPositiveIntegers() = Calc.sum 5 5 |> should equal 10

[<Test>]
[<Category("SumTests")>]
member this.OneCanSumNegativeIntegers() = Calc.sum -5 -5 |> should equal -10

[<Test>]
[<Category("SubtractTests")>]
member this.OneCanSubtractPositiveIntegers() = Calc.subtract 5 5 |> should equal 0

// Remaining test cases translated similarly