Skip to content

Commit

Permalink
test: add test for updating room environmental data
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGiulianelli committed Mar 11, 2023
1 parent fe3fd6c commit b435283
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/test/kotlin/application/service/RoomServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package application.service

import application.controller.RoomController
import entity.environment.Humidity
import entity.environment.Temperature
import entity.zone.Room
import entity.zone.RoomEnvironmentalData
Expand Down Expand Up @@ -114,4 +115,34 @@ class RoomServiceTest : StringSpec({
RoomService.GetAllRoomEntry(roomController).execute().count() shouldBe 0
}
}

"It should be possible to update the data of an existent room" {
withMongo {
val roomController = controller()
RoomService.CreateRoom(exampleRoom, roomController).execute()
RoomService.UpdateRoomEnvironmentData(
exampleRoom.id,
exampleRoom.environmentalData.copy(humidity = Humidity(55.0)),
Instant.now(),
roomController
).execute() shouldBe true
RoomService.GetRoom(exampleRoom.id, roomController, Instant.now()).execute()
?.environmentalData shouldBe RoomEnvironmentalData(
temperature = Temperature(30.3),
humidity = Humidity(55.0)
)
}
}

"It should not be possible to update the data of a room that doesn't exist" {
withMongo {
val roomController = controller()
RoomService.UpdateRoomEnvironmentData(
exampleRoom.id,
exampleRoom.environmentalData.copy(humidity = Humidity(55.0)),
Instant.now(),
roomController
).execute() shouldBe false
}
}
})

0 comments on commit b435283

Please sign in to comment.