Example #1
0
        public async Task AttendanceControllerDisplayNull()
        {
            var data = new AttendanceApiDataHandler();

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

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

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

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <AttendanceDisplayById>()), Times.Once());
        }
Example #2
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());
        }
Example #3
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());
        }