Пример #1
0
        public async Task AttendanceControllerFilter()
        {
            var data = new AttendanceApiDataHandler();
            var list = new List <AttendanceDisplay> {
                AttendanceData.GetFirstDisplay(false)
            };
            var filter = new AttendanceFilter {
                TenantRestrict = true
            };

            data.Result.Setup(m => m.Execute(It.IsAny <AttendanceDisplayByFilter>())).Returns(list);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Filter(filter) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as PagedResult <IEnumerable <AttendanceDisplay> >;

            check.Should().NotBeNull();
            check.Data.Count().Should().Be(list.Count);

            Assert.That(check.Data, Is.DeepEqualTo(list));

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <AttendanceDisplayByFilter>()), Times.Once());
        }
Пример #2
0
        public async Task DashControllerHomeTest()
        {
            var data = new HomeApiDataHandler();

            var attendance = AttendanceData.GetFirstDisplay(false);

            attendance.When = DateTime.UtcNow.AddDays(2);

            var display = new HomeDisplay
            {
                Attendances = new List <AttendanceDisplay>()
                {
                    attendance
                },
                Msgs = new List <MsgDisplay>()
                {
                    MsgData.GetFirstDisplay(false)
                },
            };

            data.Result.Setup(m => m.Execute(It.IsAny <HomeComposite>())).Returns(display);

            var controller = new DashController(data, new LogicHandler())
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Home() as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as HomeViewModel;

            check.Success.Should().BeTrue();
            check.Should().NotBeNull();
            check.Attendance.Count().Should().Be(8);
            check.Msg.Count().Should().Be(1);
            check.Attendance.First().Total.Should().Be(0);
            check.Attendance.First().When.Should().BeBefore(DateTime.UtcNow);


            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <HomeComposite>()), Times.Once());
        }
Пример #3
0
        public async Task AttendanceControllerDisplayUnauthorized()
        {
            var data    = new AttendanceApiDataHandler();
            var display = AttendanceData.GetFirstDisplay(false);

            data.Result.Setup(m => m.Execute(It.IsAny <AttendanceDisplayById>())).Returns(display);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = NonTenantUser
            };
            var result = await controller.Display(AttendanceData.FirstId) as UnauthorizedResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <UnauthorizedResult>();

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <AttendanceDisplayById>()), Times.Once());
        }
Пример #4
0
        public async Task AttendanceControllerDisplay()
        {
            var data    = new AttendanceApiDataHandler();
            var display = AttendanceData.GetFirstDisplay(false);

            data.Result.Setup(m => m.Execute(It.IsAny <AttendanceDisplayById>())).Returns(display);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = AdminUser
            };
            var result = await controller.Display(AttendanceData.FirstId) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            Assert.That(result.Value, Is.DeepEqualTo(display));

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <AttendanceDisplayById>()), Times.Once());
        }