public ActionResult SaveShiftTemplate(ShiftTemplateViewModel viewModel) { var action = new SaveShiftTemplateAction <ActionResult>(ServiceRegistry) { OnComplete = (model) => View("ShiftTemplate", model) }; return(action.Invoke(viewModel, ResolveRestaurantId())); }
public void EnsureGuardAgainstNullOnComplete() { var error = ""; try { var action = new SaveShiftTemplateAction <dynamic>(A.Fake <IServiceRegistry>()); action.Invoke(new ShiftTemplateViewModel(), 0); } catch (Exception ex) { error = ex.Message; } Assert.IsTrue(error.Contains("OnComplete")); }
public void EnsureViewModelHadErrorsIfSaveFailed() { var system = A.Fake <IServiceRegistry>(); A.CallTo(() => system.ShiftTemplateService.SaveTemplates(null)).WithAnyArguments(). Returns(new GenericServiceResponse { NotificationCollection = NotificationCollection.CreateEmpty().AddError("error") }); var action = new SaveShiftTemplateAction <dynamic>(system) { OnComplete = (m) => new { Value = m }, }; var result = action.Invoke(new ShiftTemplateViewModel(), 1).Value as ShiftTemplateViewModel; Assert.IsTrue(result.Notifications.HasErrors()); }
public void EnsureGuardAgainstNullViewModel() { var error = ""; try { var action = new SaveShiftTemplateAction <dynamic>(A.Fake <IServiceRegistry>()) { OnComplete = (m) => new { Value = true }, }; action.Invoke(null, 1); } catch (Exception ex) { error = ex.Message; } Assert.IsTrue(error.Contains("viewModel")); }