public void GetRoutesTest() { // Arrange RoutesController routeController = new RoutesController(unitOfFactory); // Act IEnumerable <RouteDTO> result1 = routeController.GetRoutes(); List <RouteDTO> list = (List <RouteDTO>)result1; var result2 = routeController.GetRoute(5); var result3 = routeController.GetRoute(-2); var contentresult = result2.Result as OkNegotiatedContentResult <RouteDTO>; // Assert Assert.IsTrue(list.Count > 0); Assert.AreEqual(5, contentresult.Content.Id); Assert.IsInstanceOfType(result3.Result, typeof(NotFoundResult)); }
public async Task GetRouteAsync() { // Arrange RoutesController controller = new RoutesController(); // Act IHttpActionResult result = await controller.GetRoute(23); var route = result as OkNegotiatedContentResult <Route>; // Assert Assert.IsNotNull(route); Assert.AreEqual(23, route.Content.RouteId); }
public async Task GetRoute_WhenRouteUnderIdExist_ReturnOkResult() { var result = await _routesController.GetRoute(1); Assert.IsInstanceOf <OkObjectResult>(result); }