public void CreatePoi_WithValidPoint_AddGuidToPOI() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); var point = new POI { TripId = "8675309", Latitude = 35.6262904, Longitude = 139.780985, PoiType = POIType.HardBrake, Timestamp = DateTime.Now }; //act controller.CreatePoi(point); var response = controller.GetByTripId("8675309") as OkObjectResult; var results = response.Value as List <POI>; var result = results.FirstOrDefault(); //assert Assert.NotNull(result); Assert.Equal(point.Latitude, result.Latitude); Assert.Equal(point.Longitude, result.Longitude); Assert.Equal(point.TripId, result.TripId); } }
public void GetByTripId_WithValidTripId_Returns_CorrectPoint() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); //act var point = TestData.FirstOrDefault(); var result = controller.GetByTripId(point.TripId); var okResult = result as OkObjectResult; var poiResults = okResult.Value as List <POI>; var poiResult = poiResults.FirstOrDefault(); //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); } }
public void GetByTripId_WithInvalidTripId_Returns_EmptyList() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); //act var point = TestData.FirstOrDefault(); var result = controller.GetByTripId("fake_trip_id"); //assert var poiResult = result as OkObjectResult; var poiList = poiResult.Value as List <POI>; Assert.Empty(poiList); } }
public void GetByTripId_WithValidTripId_Returns_SuccessStatus() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); //act var point = TestData.FirstOrDefault(); var result = controller.GetByTripId(point.TripId); var okResult = result as OkObjectResult; //assert Assert.IsType <OkObjectResult>(result); Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); } }
public void GetByTripId_WithInvalidTripId_Returns_OkObjectResult() { using (var context = new POIContext(ContextOptions)) { //arrange var controller = new POIController(context); //act var point = TestData.FirstOrDefault(); var result = controller.GetByTripId("fake_trip_id"); //assert Assert.NotNull(result); Assert.IsType <OkObjectResult>(result); var poiResult = result as OkObjectResult; Assert.Equal(200, poiResult.StatusCode); } }