Ejemplo n.º 1
0
        public JsonResult SaveShift(TimeSpan startTime, TimeSpan endTime, DateTime shiftDate, int waiterId, string containerId)
        {
            var action = new SaveShiftAction <JsonResult>(ServiceRegistry)
            {
                OnComplete = (model) => new JsonResult()
                {
                    Data = new { ShiftContainerId = containerId, Payload = this.RenderPartialViewToString("ShiftsResult", model) }
                }
            };

            return(action.Invoke(startTime, endTime, shiftDate, waiterId, ResolveRestaurantId()));
        }
Ejemplo n.º 2
0
        public void EnsureGuardAgainstNullOnComplete()
        {
            var error = "";

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

                action.Invoke(new TimeSpan(), new TimeSpan(), DateTime.Now, 0, 0);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            Assert.IsTrue(error.Contains("OnComplete"));
        }
Ejemplo n.º 3
0
        public void EnsureResultHasErrorsIfAny()
        {
            var system = A.Fake <IServiceRegistry>();

            A.CallTo(() => system.ShiftService.SaveShift(null)).WithAnyArguments()
            .Returns(new GenericServiceResponse
            {
                NotificationCollection = NotificationCollection.CreateEmpty().AddError("error")
            });

            A.CallTo(() => system.ShiftService.LoadShifts(null)).WithAnyArguments().Returns(new LoadShiftCollectionResponse()
            {
                Shifts = new List <ShiftDto>()
            });

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

            var result = action.Invoke(new TimeSpan(), new TimeSpan(), DateTime.Now, 0, 0).Model as ShiftsResultViewModel;

            Assert.IsTrue(result.HasErrors);
        }