public async Task GetBySensor_WhenCalled_UnknownSensor_ReturnsNotFound() { var mockedRepo = new Mock <IHomeRepository>(); var room = new Room() { Name = "test_room_1" }; mockedRepo.Setup(repo => repo.GetRoomBySensorId(Guid.Parse("00000000-0000-0000-0000-000000000001"))).ReturnsAsync((Room)null); var mockedListenerClient = new Mock <ISensorListenerAPI>(); mockedListenerClient.Setup(client => client.NotifyHomeyTopic <double>("test", 0)); var controller = new RoomsController(mockedRepo.Object, mockedListenerClient.Object); var result = await controller.GetBySensor("00000000-0000-0000-0000-000000000001"); var contentResult = result as NotFoundResult; Assert.NotNull(contentResult); }