public void Test_DeleteStation_ReturnsNotFoundResult() { // Arrange var mockRepo = new Mock <IMongoDataRepository <Station> >(); var mockHub = new Mock <IHubContext <LiveStationHub> >(); var controller = new StationsController(mockRepo.Object, mockHub.Object, Mapper); // Act var notFoundResult = controller.DeleteStation(ObjectId.GenerateNewId().ToString()); // Assert Assert.IsType <NotFoundResult>(notFoundResult.Result); }
public void Test_DeleteStation_ReturnsOkResult() { // Arrange var mockRepo = new Mock <IMongoDataRepository <Station> >(); double[] position = new double[] { 30.2, 50.3 }; Station station = this.Mock.MockStation(position); station.Id = ObjectId.GenerateNewId(); station.CreatedAt = station.UpdatedAt = DateTime.UtcNow; mockRepo.Setup(repo => repo.GetObjectByIdAsync(station.Id.ToString())) .Returns(Task.FromResult(station)); var mockHub = new Mock <IHubContext <LiveStationHub> >(); var controller = new StationsController(mockRepo.Object, mockHub.Object, Mapper); // Act var okResult = controller.DeleteStation(station.Id.ToString()); // Assert Assert.IsType <OkObjectResult>(okResult.Result); }