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()); }
public ActionResult Add() { var action = new LoadStaffMemberAction <ActionResult>(ServiceRegistry) { OnComplete = (model) => View("EditStaffMember", model) }; return(action.Invoke(ResolveRestaurantId())); }
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)); }
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()); }
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")); }
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)); }
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()); }