Example #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());
        }