示例#1
0
        public ActionResult SaveShiftTemplate(ShiftTemplateViewModel viewModel)
        {
            var action = new SaveShiftTemplateAction <ActionResult>(ServiceRegistry)
            {
                OnComplete = (model) => View("ShiftTemplate", model)
            };

            return(action.Invoke(viewModel, ResolveRestaurantId()));
        }
示例#2
0
        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"));
        }
示例#3
0
        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());
        }
示例#4
0
        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"));
        }