Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type UnitQuantity = private UnitQuantity of int
- // ^ private constructor
- // define a module with the same name as the type
- module UnitQuantity =
- /// Define a "smart constructor" for UnitQuantity
- /// int -> Result<UnitQuantity,string>
- let create qty =
- if qty < 1 then
- // failure
- Error "UnitQuantity can not be negative"
- else if qty > 1000 then
- // failure
- Error "UnitQuantity can not be more than 1000"
- else
- // success -- construct the return value
- Ok (UnitQuantity qty)
- let ``Check UnitQuantity.create is one`` () =
- // ARRANGE
- let expected = 1
- // ACT
- //let unitQtyResult = UnitQuantity.create 1
- match UnitQuantity.create 1 with
- | Error msg -> 0
- //printfn "Failure, Message is %s" msg
- | Ok x -> 0
- // let innerValue = UnitQuantity.value actual
- // ASSERT
- //Assert.Equal(expected,actual)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement