public void DeleteRouteRouteNotExists() { try { _routesController.Delete(new DeleteRouteRequest { PointFromCode = _routeBase.PointFromCode, PointToCode = _routeBase.PointToCode }); } catch (ResponseException) { } }
public void DeleteTest() { var controller = new RoutesController(); var result = controller.Delete(1) as ViewResult; var route = result.Model as Route; Assert.IsTrue(route.RouteName == "Route - 1"); }
public void TestPostDeleteRouteNotExsist() { // Arrange var controller = new RoutesController(new RouteLogic(new RouteRepositoryStub()), new StationLogic(new StationRepositoryStub())); // ACt var result = controller.Delete(100) as HttpNotFoundResult; // Assert Assert.AreEqual(404, result.StatusCode); }
public void TestPostDelete() { // Arrange var controller = new RoutesController(new RouteLogic(new RouteRepositoryStub()), new StationLogic(new StationRepositoryStub())); // ACt var result = (ViewResult)controller.Delete(1); // Assert Assert.AreEqual("", result.ViewName); }
public async Task DeleteGet_ReturnsANotFoundResult_WhenIdIsNull() { // Arrange var mockRoutesRepo = new Mock <IRoutesRepository>(); var mockPointsRepo = new Mock <IPointsRepository>(); var controller = new RoutesController(mockRoutesRepo.Object, mockPointsRepo.Object); // Act var result = await controller.Delete(null); // Assert Assert.IsType <NotFoundResult>(result); }
public async Task DeleteGet_ReturnsANotFoundResult_WhenRouteReturnedIsNull() { // Arrange var mockRoutesRepo = new Mock <IRoutesRepository>(); mockRoutesRepo.Setup(repo => repo.GetRouteByID(1)).Returns(Task.FromResult((Route)null)); var mockPointsRepo = new Mock <IPointsRepository>(); var controller = new RoutesController(mockRoutesRepo.Object, mockPointsRepo.Object); // Act var result = await controller.Delete(1); // Assert Assert.IsType <NotFoundResult>(result); }
public async Task DeleteGet_ReturnsAViewResult_WithRoute() { // Arrange var mockRoutesRepo = new Mock <IRoutesRepository>(); mockRoutesRepo.Setup(repo => repo.GetRouteByID(1)).Returns(Task.FromResult(GetTestRoutes()[0])); var mockPointsRepo = new Mock <IPointsRepository>(); var controller = new RoutesController(mockRoutesRepo.Object, mockPointsRepo.Object); // Act var result = await controller.Delete(1); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <Route>(viewResult.ViewData.Model); Assert.Equal(GetTestRoutes()[0], model); }