public async Task ExecuteShouldReturnUsersWithAdministrator() { SchoolManagementContext context = new ContextBuilder().BuildClean(); //Arrange new UserBuilder(context).With(x => x.FirstName = "Firs name") .With(x => x.LastName = "SuperAdmin") .WithRole(x => x.WithName(Roles.SuperAdmin)).BuildAndSave(); new UserBuilder(context).With(x => x.FirstName = "Firs name") .With(x => x.LastName = "Admin") .WithRole(x => x.WithName(Roles.Admin)).BuildAndSave(); new UserBuilder(context).With(x => x.FirstName = "Firs name") .With(x => x.LastName = "Anchor") .WithRole(x => x.WithName(Roles.Anchor)).BuildAndSave(); new UserBuilder(context).With(x => x.FirstName = "Firs name") .With(x => x.LastName = "Participant") .WithRole(x => x.WithName(Roles.Participant)).BuildAndSave(); //Act Query query = new Query() { IsIncludeAdministrators = true }; UsersListVierModel result = await new Handler(context).Handle(query, CancellationToken.None); //Arrange Assert.NotNull(result); Assert.NotEmpty(result.UserDtoList); Assert.Equal(3, result.UserDtoList.Count); }
public async Task <IActionResult> Index(CancellationToken cancellationToken) { Query query = new Query { IsIncludeAdministrators = User.HasPermissionClaim(Permissions.Users.ShowAdministrator) }; UsersListVierModel usersListVierModel = await _mediator.Send(query, cancellationToken); return(View("UserList/Index", usersListVierModel)); }