public void GetById_WithValidId_Returns_SuccessStatus() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); //act var point = TestData.FirstOrDefault(); var result = controller.GetById(point.Id); var okResult = result as OkObjectResult; //assert Assert.IsType <OkObjectResult>(result); Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); } }
public void GetById_WithInvalidId_Returns_NotFoundResult() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); //act var point = TestData.FirstOrDefault(); var result = controller.GetById("fake_id"); //assert Assert.NotNull(result); Assert.IsType <NotFoundResult>(result); var notFoundResult = result as NotFoundResult; Assert.Equal(404, notFoundResult.StatusCode); } }
public void GetById_WithValidId_Returns_CorrectPoint() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); //act var point = TestData.FirstOrDefault(); var result = controller.GetById(point.Id); var okResult = result as OkObjectResult; var poiResult = okResult.Value as POI; //assert Assert.NotNull(okResult.Value); Assert.Equal(point.TripId, poiResult.TripId); Assert.Equal(point.Latitude, poiResult.Latitude); Assert.Equal(point.Longitude, poiResult.Longitude); Assert.Equal(point.PoiType, poiResult.PoiType); Assert.Equal(point.Deleted, poiResult.Deleted); Assert.Equal(point.Timestamp, poiResult.Timestamp); } }