Beispiel #1
0
        public void EnsureWaiterIsLoadedAndWaitersAreLoadedIfWaiterIdIsNotNull()
        {
            var system = A.Fake <IServiceRegistry>();
            var waiter = new StaffDto {
                Id = 1, EmailAddress = "*****@*****.**"
            };
            var user = A.Fake <MembershipUser>();

            A.CallTo(() => user.GetPassword()).Returns("pass");

            A.CallTo(() => system.StaffService.LoadStaffMember(null)).WithAnyArguments().Returns(new StaffResponse {
                Staff = waiter
            });

            var action = new LoadStaffMemberAction <dynamic>(system)
            {
                OnComplete = (m) => new { Value = m },
            };

            var result = action.Invoke(1, 1).Value as StaffMemberViewModel;


            Assert.IsTrue(result.Staff.Id == 1);
            Assert.IsFalse(result.Notifications.HasErrors());
        }
Beispiel #2
0
        public ActionResult Add()
        {
            var action = new LoadStaffMemberAction <ActionResult>(ServiceRegistry)
            {
                OnComplete = (model) => View("EditStaffMember", model)
            };

            return(action.Invoke(ResolveRestaurantId()));
        }
Beispiel #3
0
        public ActionResult EditFailed(int?id, NotificationCollection errors)
        {
            var action = new LoadStaffMemberAction <ActionResult>(ServiceRegistry)
            {
                OnComplete = (model) =>
                {
                    model.Notifications = errors;
                    return(View("EditStaffMember", model));
                }
            };

            return(action.Invoke(ResolveRestaurantId(), id));
        }
Beispiel #4
0
        public void EnsureWaiterIsNotNullIfWaiterIdIsNull()
        {
            var system = A.Fake <IServiceRegistry>();

            var action = new LoadStaffMemberAction <dynamic>(system)
            {
                OnComplete = (m) => new { Value = m },
            };

            var result = action.Invoke(1, 1).Value as StaffMemberViewModel;

            Assert.IsNotNull(result.Staff);
            Assert.IsTrue(result.Notifications.HasErrors());
        }
Beispiel #5
0
        public void EnsureGuardAgainstNullOnComplete()
        {
            var error = "";

            try
            {
                var action = new LoadStaffMemberAction <dynamic>(A.Fake <IServiceRegistry>());

                action.Invoke(1, 1);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            Assert.IsTrue(error.Contains("OnComplete"));
        }
Beispiel #6
0
        public ActionResult ManageStaffMemberLeave(int staffMemberId, NotificationCollection notifications = null)
        {
            var action = new LoadStaffMemberAction <ActionResult>(ServiceRegistry)
            {
                OnComplete = (model) =>
                {
                    model.ShowLeave = true;
                    if (notifications.IsNotNull())
                    {
                        model.LeaveErrors = notifications;
                    }
                    return(View("EditStaffMember", model));
                }
            };

            return(action.Invoke(ResolveRestaurantId(), staffMemberId));
        }
Beispiel #7
0
        public void EnsureModelHasErrorsIfFailedToLoadWaiter()
        {
            var system = A.Fake <IServiceRegistry>();

            var genericWaiterRequest = new LoadStaffMemberRequest {
                StaffId = 1
            };

            A.CallTo(() => system.StaffService.LoadStaffMember(genericWaiterRequest)).Returns(null);

            var action = new LoadStaffMemberAction <dynamic>(system)
            {
                OnComplete = (m) => new { Value = m },
            };

            var result = action.Invoke(1, 1).Value as StaffMemberViewModel;

            Assert.IsNotNull(result.Staff);
            Assert.IsTrue(result.Notifications.HasErrors());
        }