public static Hall GetHallByName(string name) { try { return(HallController.GetByName(name)); } catch (Exception e) { return(new Hall()); } }
public static Hall GetHallById(int id) { try { return(HallController.Get(id)); } catch (Exception e) { return(new Hall()); } }
public static List <Hall> GetAllHalls() { try { return(HallController.All()); } catch (Exception e) { return(new List <Hall>()); } }
public static bool HallDeleteValidation(int id) { try { HallController.Delete(id); return(true); } catch (Exception e) { return(false); } }
public static bool HallUpdateValidation(int id, string name) { try { HallController.Update(id, name); return(true); } catch (Exception e) { return(false); } }
public static bool HallAddValidation(string name) { try { if (name == null || GetHallByName(name).Name != null) { return(false); } HallController.Add(name); return(true); } catch (Exception e) { return(false); } }
public async Task Create_RouteTypeInvalidInput_RedirectToActionCreateHall() { // Arrange var mockService = new Mock <IHallService>(); HallController controller = new HallController(mockService.Object); var hallListViewModel = new HallCreateViewModel { Name = "boulder", Type = (RouteType)4 }; // Act var result = await controller.Create(hallListViewModel); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Hall", redirectToActionResult.ControllerName); Assert.Equal("Create", redirectToActionResult.ActionName); mockService.Verify(service => service.AddHall(It.IsAny <string>(), It.IsAny <RouteType>()), Times.Never); }
public async Task Delete_InvalidNullAsId_RedirectToActionCreateHall() { // Arrange var mockService = new Mock <IHallService>(); HallController controller = new HallController(mockService.Object); var hallCreateViewModel = new HallCreateViewModel { ID = null }; // Act var result = await controller.Delete(hallCreateViewModel); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Hall", redirectToActionResult.ControllerName); Assert.Equal("Create", redirectToActionResult.ActionName); mockService.Verify(service => service.DeleteHall(It.IsAny <int?>()), Times.Never); }
public void List_RouteHall_ReturnViewModel() { // Arrange var mockService = new Mock <IHallService>(); mockService.Setup(service => service.GetActiveHalls()) .Returns(new List <RouteHall> { new RouteHall(), new RouteHall() }); HallController controller = new HallController(mockService.Object); // Act var result = controller.Create(); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <HallCreateViewModel>( viewResult.ViewData.Model); Assert.Equal(2, model.Halls.Count); }
public void Init() { hall = new HallController(); }