This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [<Property>] | |
| let ``PositiveInt don't gets created if value is negative`` () = | |
| Arb.generate<int> | |
| |> Gen.filter ((>) 0) | |
| |> Arb.fromGen | |
| |> Prop.forAll <| fun x -> | |
| None = posInt x | |
| [<Property>] | |
| let ``PositiveInt gets created if value isn't negative`` (FsCheck.PositiveInt x) = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ISBN13 | |
| { | |
| public ISBN13(string value) | |
| { | |
| ValidateStringNullOrEmpty(value); | |
| ValidateStringLength(value, 13); | |
| ValidateStringMatches(value, "[0-9]{9}"); | |
| ValidateISBNCheckSum(value); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ISBN13 = private ISBN13 of string | |
| let ifTrueThen x = function | |
| | true -> Some x | |
| | false -> None | |
| let (|NullOrEmpty|_|) = | |
| String.IsNullOrEmpty | |
| >> ifTrueThen NullOrEmpty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Book = | |
| { ISBN13 : string | |
| Author : String50 | |
| Pages : PositiveInt } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class String50 | |
| { | |
| public String50(string value) | |
| { | |
| if (string.IsNullOrEmpty(value)) | |
| { | |
| throw new ArgumentException(nameof(value)); | |
| } | |
| if (value.Length > 50) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type String50 = private String50 of string | |
| let ifTrueThen succ = function | |
| | true -> Some succ | |
| | false -> None | |
| let (|NullOrEmpty|_|) = | |
| String.IsNullOrEmpty | |
| >> ifTrueThen NullOrEmpty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Book = | |
| { ISBN13 : string | |
| Author : string | |
| Pages : PositiveInt } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let (|Negative|_|) x = if x < 0 then Some Negative else None | |
| let posInt x = function | |
| | Negative -> None | |
| | x -> Some <| PositiveInt x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type PositiveInt = private PositiveInt of int | |
| let posInt x = function | |
| | x when x < 0 -> None | |
| | x -> Some <| PositiveInt x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Book = | |
| { ISBN13 : string | |
| Author : string | |
| Pages : int } |