This project is read-only.

namespace TestSpace

 

[<AutoOpen>]

module TestUtils =

    open Microsoft.VisualStudio.TestTools.UnitTesting

    let inline (==) a b = Assert.AreEqual(a,b)

    let inline (!=) a b = Assert.AreNotEqual(a,b)

    let inline (===) a b = Assert.AreSame(a,b)

    let inline (?+) a = Assert.IsTrue(a)  //+ stands for TRUE

    let inline (?-) b = Assert.IsFalse(b) //- stands for FALSE

    let inline agreeTo sourceFunction targetFunction input =

        let source = input |> sourceFunction

        let target = input |> targetFunction

        let compareFunction a b = if a=b then 0 else -1

        let compareResult = Seq.compareWith compareFunction source target

        if compareResult <> 0 then failwith "sequence not equal"

    let inline nullFunction x = x

 

module TestFsharp =

 

    open Microsoft.VisualStudio.TestTools.UnitTesting

 

    type SampleClassType(arg0, arg1) =

        member x.Sum = arg0 + arg1

        member x.GetSeq() = [arg0..arg1]

 

    let t = SampleClassType(2, 5)

    let y = t.Sum

    let z = 0

 

    [<TestClass>]

    type TestCaseUtil() =

        [<TestMethod>]

        [<TestCategory("TestFsharp")>]

        [<Description("Assert Not Equal")>]

        member this.AssertNot() =

            5 == 5

            ()

        [<TestMethod>]

        [<TestCategory("TestFsharp")>]

        [<Description("Assert Equal")>]

        member this.AssertEqual() =

            y==7

 

        [<TestMethod>]

        [<TestCategory("TestFsharp")>]

        [<Description("Assert Same Seq")>]

        member this.AssertSeqSame() =

            agreeTo (t.GetSeq) (fun _ -> [2..5]) ()

Last edited Mar 5, 2012 at 11:14 PM by ttliu2000, version 1

Comments

No comments yet.