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
| [Fact] | |
| public void Delete_WithMessageId_ShouldDeleteMessage() | |
| { | |
| // Arrange | |
| var messageId = Guid.NewGuid().ToString(); | |
| var repo = new Mock<IMessageRepository>(); | |
| repo.Setup(r => r.DeleteMessage(messageId)).Returns(1); | |
| var cache = new Mock<IMessageCache>(); | |
| cache.Setup(c => c.Get(messageId)).Returns(Cache.NotInCache); |
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
| restaurant fully booked always exceeds capacity failed | |
| { Name = GuestName "xycQKLpdXBCspKq" | |
| Quantity = Quantity 1 | |
| Date = Date 30/11/2023 00:00:00 +00:00 } [{ Name = GuestName "kWWQQebC" | |
| Quantity = Quantity 15 | |
| Date = Date 18/11/2023 00:00:00 +00:00 }; | |
| { Name = GuestName "mnvWmFjdYSwqlfJDh" | |
| Quantity = Quantity 14 | |
| Date = Date 19/11/2023 00:00:00 +00:00 }; | |
| { Name = GuestName "ICg" |
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
| restaurant tests.restaurant accepts reservation within two weeks if the requested quantity is available failed | |
| Failed after 2 tests. Parameters: | |
| ({ Name = GuestName "jd" | |
| Quantity = Quantity 19 | |
| Date = Date 01/12/2023 00:00:00 +00:00 }, []) | |
| Label of failing property: | |
| capacity on 2023-12-01: 0 |
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
| module Label = | |
| let capacityOn d current = | |
| List.filter (fun x -> x.Date = d) current | |
| |> List.sumBy Reservation.quantity | |
| |> (sprintf "\n\tcapacity on %A: %i" d) | |
| testProperty "restaurant accepts reservation within two weeks if the requested quantity is available" <| fun () -> | |
| withGen Gen.Reservation.available <| fun (addition, current) -> | |
| reserveTable current addition = Ok (addition :: current) | |
| |@ (Label.capacityOn addition.Date current) |
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
| restaurant tests.restaurant with no reservations always accepts reservation failed | |
| Failed after 18 tests. Parameters: | |
| { Name = GuestName "GA" | |
| Quantity = Quantity 20 | |
| Date = Date 23/11/2023 00:00:00 +00:00 } | |
| reserveTable [] r = Ok([r]) | |
| reserveTable [] { Name = GuestName "GA" | |
| Quantity = Quantity 20 | |
| Date = Date 23/11/2023 00:00:00 +00:00 } = Ok([{ Name = GuestName "GA" |
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
| open Swensen.Unquote | |
| testProperty "restaurant with no reservations always accepts reservation" <| fun r -> | |
| test <@ reserveTable [] r = Ok [r] @> |
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
| open FPrimitive | |
| module Folder = | |
| /// Alphanum10 -> Folder list -> Result<Folder, ErrorsByTag> | |
| let create id xs = result { | |
| let! children = specResult xs { | |
| tag "folder.width" | |
| inclusiveBetweenOf List.length 0 Folder.Limits.maxWidth $"require a max of {Folder.Limits.maxWidth} children on each level" } | |
| let x = { Id = id; Children = children } |
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 Folder = | |
| private { Id : Alphanum10 | |
| Children : Folder list } |
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
| open FsCheck | |
| module Gen = | |
| module FolderDto = | |
| let tooWide = | |
| tree 0 maxDepth 10 10 (fun xs -> | |
| Folder.id | |
| |> Gen.map (fun x -> Tree.create x.Value xs)) | |
| |> Gen.filter (fun t -> t.Branches <> []) | |
| |> Gen.map treeToDto |
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
| open FsCheck | |
| module Gen = | |
| // int -> int -> int -> int -> ('a list -> Gen<'a>) -> Gen<'a> | |
| let tree minDepth maxDepth minWidth maxWidth factory = | |
| Gen.sized <| fun s -> | |
| let rec recurse depth s = | |
| if s = 0 || depth >= maxDepth | |
| then factory [] | |
| else gen { |