public void GetCreateShould_ReturnErrorView_WhenPassedIdIsNull() { var consumableServiceMock = new Mock <IConsumableService>(); var placeServiceMock = new Mock <IPlaceService>(); var facctoryMock = new Mock <IViewModelFactory>(); var controller = new Web.Controllers.ConsumablesController(consumableServiceMock.Object, placeServiceMock.Object, facctoryMock.Object); controller .WithCallTo(c => c.Create(null)) .ShouldRenderView("Error"); }
public void AddConsumableShould_ReturnViewWithCorrectModel_WhenModelIssValid() { var consumableServiceMock = new Mock <IConsumableService>(); var placeServiceMock = new Mock <IPlaceService>(); var facctoryMock = new Mock <IViewModelFactory>(); var controller = new Web.Controllers.ConsumablesController(consumableServiceMock.Object, placeServiceMock.Object, facctoryMock.Object); var model = new ConsumableViewModel(); controller .WithCallTo(c => c.AddConsumable(model)) .ShouldRenderPartialView("_Consumable") .WithModel(model); }
public void AddConsumableShould_ReturnSameView_WhenModelIsNotValid() { var consumableServiceMock = new Mock <IConsumableService>(); var placeServiceMock = new Mock <IPlaceService>(); var facctoryMock = new Mock <IViewModelFactory>(); var controller = new Web.Controllers.ConsumablesController(consumableServiceMock.Object, placeServiceMock.Object, facctoryMock.Object); var model = new ConsumableViewModel(); controller.ModelState.AddModelError("key", "message"); controller .WithCallTo(c => c.AddConsumable(model)) .ShouldRenderPartialView("_ConsumableForm") .WithModel(model); }
public void GetNewFormShould_ReturnViewWithCorrectModel_WhenPassedIdIsNotNull() { var consumableServiceMock = new Mock <IConsumableService>(); var placeServiceMock = new Mock <IPlaceService>(); var factoryMock = new Mock <IViewModelFactory>(); var controller = new Web.Controllers.ConsumablesController(consumableServiceMock.Object, placeServiceMock.Object, factoryMock.Object); var id = Guid.NewGuid(); var model = new ConsumableViewModel() { PlaceId = id }; factoryMock.Setup(f => f.CreateConsumableViewModel(id)).Returns(model); controller .WithCallTo(c => c.GetNewForm(id)) .ShouldRenderPartialView("_ConsumableForm") .WithModel(model); }
public void GetCreateShould_ReturnViewWithCorrectModel_WhenPassedIdIsNotNull() { var consumableServiceMock = new Mock <IConsumableService>(); var placeServiceMock = new Mock <IPlaceService>(); var facctoryMock = new Mock <IViewModelFactory>(); var controller = new Web.Controllers.ConsumablesController(consumableServiceMock.Object, placeServiceMock.Object, facctoryMock.Object); var id = Guid.NewGuid(); var emptyList = new List <Consumable>(); var model = new CreateMenuViewModel(); model.Menu = emptyList; model.PlaceId = id; consumableServiceMock.Setup(s => s.GetAllConsumablesOf(id)).Returns(emptyList.AsQueryable()); facctoryMock.Setup(s => s.CreateMenuViewModel(id, emptyList)).Returns(model); controller .WithCallTo(c => c.Create(id)) .ShouldRenderView("CreateMenu") .WithModel(model); }