public async Task Should_Work_For_Existing_User() { //Arrange var adminUser = await GetUserByUserNameOrNullAsync(User.AdminUserName); var managerRole = CreateRole("Manager"); var roleCount = UsingDbContext(context => context.Roles.Count(r => r.TenantId == AbpSession.TenantId)); //Act var output = await UserAppService.GetUserForEdit(new NullableIdDto <long> { Id = adminUser.Id }); //Assert output.User.Id.ShouldBe(adminUser.Id); output.User.Name.ShouldBe(adminUser.Name); output.User.Password.ShouldBe(null); output.Roles.Length.ShouldBe(roleCount); var managerRoleDto = output.Roles.FirstOrDefault(r => r.RoleName == managerRole.Name); managerRoleDto.ShouldNotBe(null); managerRoleDto.RoleId.ShouldBe(managerRole.Id); managerRoleDto.IsAssigned.ShouldBe(false); var adminRoleDto = output.Roles.FirstOrDefault(r => r.RoleName == StaticRoleNames.Tenants.Admin); adminRoleDto.ShouldNotBe(null); adminRoleDto.IsAssigned.ShouldBe(true); }
public async Task Should_Work_For_NonExisting_User() { //Arrange LoginAsHostAdmin(); //Act var output = await UserAppService.GetUserForEdit(new NullableIdDto <long>()); //Assert output.User.Id.ShouldBe(null); output.User.Name.ShouldBe(null); output.User.Password.ShouldBe(null); output.Roles.Length.ShouldBe(1); output.Roles.Any(r => r.RoleName == StaticRoleNames.Host.Admin).ShouldBe(true); output.Roles.Single(r => r.RoleName == StaticRoleNames.Host.Admin).IsAssigned.ShouldBe(true); }