Skip to content

Commit

Permalink
✅ Fix traveling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyfran committed Oct 19, 2024
1 parent 2cf75ec commit a2728f2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Duets.Entities/Duets.Entities.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ItemGroup>
<Compile Include="Types\Common.Types.fs"/>
<Compile Include="Types\City.Types.fs"/>
<Compile Include="Types\World.Coordinates.Types.fs"/>
<Compile Include="Types\Calendar.Types.fs"/>
<Compile Include="Types\Genre.Types.fs"/>
<Compile Include="Types\Instrument.Types.fs"/>
Expand All @@ -24,7 +25,6 @@
<Compile Include="Types\Places\RehearsalSpace.Types.fs"/>
<Compile Include="Types\Places\Studio.Types.fs"/>
<Compile Include="Types\Places\Shop.Types.fs"/>
<Compile Include="Types\World.Coordinates.Types.fs"/>
<Compile Include="Types\Item.Types.fs"/>
<Compile Include="Types\Merch.Types.fs"/>
<Compile Include="Types\World.Types.fs"/>
Expand Down
36 changes: 32 additions & 4 deletions tests/Simulation.Tests/World/Traveling.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,50 @@ open Duets.Simulation
let private hotelInPrague =
Queries.World.placesByTypeInCity Prague PlaceTypeIndex.Hotel |> List.head

let private barInPrague =
Queries.World.placesByTypeInCity Prague PlaceTypeIndex.Bar |> List.head
let private hospitalInPrague =
Queries.World.placesByTypeInCity Prague PlaceTypeIndex.Hospital |> List.head

let private hotelInNewYork =
Queries.World.placesByTypeInCity NewYork PlaceTypeIndex.Hotel |> List.head

let private bookstoreInSohoNewYork =
Queries.World.placesByTypeInCity NewYork PlaceTypeIndex.Bookstore
|> List.find (fun place -> place.Zone.Name = "SoHo")

let private cafeInSohoNewYork =
Queries.World.placesByTypeInCity NewYork PlaceTypeIndex.Cafe
|> List.find (fun place -> place.Zone.Name = "SoHo")

[<Test>]
let ``traveling to another place inside the same city consumes 30 minutes`` () =
let ``traveling to another place inside the same city but in another region consumes 30 minutes``
()
=
let effects =
WorldMoveToPlace(
Diff((Prague, hotelInPrague.Id, 1), (Prague, barInPrague.Id, 1))
Diff(
(Prague, hotelInPrague.Id, 1),
(Prague, hospitalInPrague.Id, 1)
)
)
|> Simulation.tickOne dummyState

effects |> fst |> should contain (TurnTimeUpdated 30<minute>)

[<Test>]
let ``traveling to another place inside the same city but in the same region consumes 15 minutes``
()
=
let effects =
WorldMoveToPlace(
Diff(
(NewYork, bookstoreInSohoNewYork.Id, 1),
(NewYork, cafeInSohoNewYork.Id, 1)
)
)
|> Simulation.tickOne dummyState

effects |> fst |> should contain (TurnTimeUpdated 15<minute>)

[<Test>]
let ``traveling to another city does not add 30 minutes on top of flight time``
()
Expand Down

0 comments on commit a2728f2

Please sign in to comment.