public async Task VisibleControllerFilter() { var data = new VisibleApiDataHandler(); var list = new List <VisibleDisplay> { VisibleData.GetFirstDisplay() }; var filter = new VisibleFilter { TenantRestrict = true }; data.Result.Setup(m => m.Execute(It.IsAny <VisibleDisplayByFilter>())).Returns(list); var controller = new VisibleController(data, Cloud, 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 <VisibleDisplay> >; 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 <VisibleDisplayByFilter>()), Times.Once()); }
public async Task VisibleControllerFilterUnauthorized() { var data = new VisibleApiDataHandler(); var filter = new VisibleFilter { TenantRestrict = false }; data.Result.Setup(m => m.Execute(It.IsAny <VisibleDisplayByFilter>())).Returns(new List <VisibleDisplay>()); var controller = new VisibleController(data, Cloud, Logic) { CurrentUser = NonTenantUser }; var result = await controller.Filter(filter) as OkObjectResult; result.Should().NotBeNull(); result.Should().BeOfType <OkObjectResult>(); var check = result.Value as PagedResult <IEnumerable <VisibleDisplay> >; check.Data.Count().Should().Be(0); data.HasExecuted.Should().BeTrue(); data.Result.Verify(s => s.Execute(It.IsAny <VisibleDisplayByFilter>()), Times.Once()); }