Abp.Zero.SampleApp.Tests.Users.UserOrganizationUnit_Tests.GetOU(string)

Here are the examples of the csharp api class Abp.Zero.SampleApp.Tests.Users.UserOrganizationUnit_Tests.GetOU(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

12 Examples 7

1. Example

View license
[Fact]
        public async Task Test_AddToOrganizationUnitAsync()
        {
            //Arrange
            var ou2 = GetOU("OU2");

            //Act
            await _userManager.AddToOrganizationUnitAsync(_defaultTenantAdmin, ou2);

            //Assert
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, ou2)).ShouldBe(true);
            UsingDbContext(context => context.UserOrganizationUnits.FirstOrDefault(ou => ou.UserId == _defaultTenantAdmin.Id && ou.OrganizationUnitId == ou2.Id).ShouldNotBeNull());
        }

2. Example

View license
[Fact]
        public async Task Test_RemoveFromOrganizationUnitAsync()
        {
            //Arrange
            var ou11 = GetOU("OU11");

            //Act
            await _userManager.RemoveFromOrganizationUnitAsync(_defaultTenantAdmin, ou11);

            //Assert
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, ou11)).ShouldBe(false);
            UsingDbContext(context => context.UserOrganizationUnits.FirstOrDefault(ou => ou.UserId == _defaultTenantAdmin.Id && ou.OrganizationUnitId == ou11.Id).IsDeleted.ShouldBeTrue());
        }

3. Example

View license
[Fact]
        public async Task Test_IsInOrganizationUnitAsync()
        {
            //Act & Assert
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, GetOU("OU11"))).ShouldBe(true);
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, GetOU("OU2"))).ShouldBe(false);
        }

4. Example

View license
[Fact]
        public async Task Test_GetUsersInOrganizationUnit()
        {
            //Act & Assert
            (await _userManager.GetUsersInOrganizationUnit(GetOU("OU11"))).Count.ShouldBe(1);
            (await _userManager.GetUsersInOrganizationUnit(GetOU("OU1"))).Count.ShouldBe(0);
            (await _userManager.GetUsersInOrganizationUnit(GetOU("OU1"), true)).Count.ShouldBe(1);
        }

5. Example

View license
[Fact]
        public async Task Test_RemoveFromOrganizationUnitAsync()
        {
            //Arrange
            var ou11 = GetOU("OU11");

            //Act
            await _userManager.RemoveFromOrganizationUnitAsync(_defaultTenantAdmin, ou11);

            //Assert
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, ou11)).ShouldBe(false);
            UsingDbContext(context => context.UserOrganizationUnits.FirstOrDefault(ou => ou.UserId == _defaultTenantAdmin.Id && ou.OrganizationUnitId == ou11.Id).IsDeleted.ShouldBeTrue());
        }

6. Example

View license
[Fact]
        public async Task Test_AddToOrganizationUnitAsync()
        {
            //Arrange
            var ou2 = GetOU("OU2");

            //Act
            await _userManager.AddToOrganizationUnitAsync(_defaultTenantAdmin, ou2);

            //Assert
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, ou2)).ShouldBe(true);
            UsingDbContext(context => context.UserOrganizationUnits.FirstOrDefault(ou => ou.UserId == _defaultTenantAdmin.Id && ou.OrganizationUnitId == ou2.Id).ShouldNotBeNull());
        }

7. Example

View license
[Fact]
        public async Task Test_GetUsersInOrganizationUnit()
        {
            //Act & Assert
            (await _userManager.GetUsersInOrganizationUnit(GetOU("OU11"))).Count.ShouldBe(1);
            (await _userManager.GetUsersInOrganizationUnit(GetOU("OU1"))).Count.ShouldBe(0);
            (await _userManager.GetUsersInOrganizationUnit(GetOU("OU1"), true)).Count.ShouldBe(1);
        }

8. Example

View license
[Fact]
        public async Task Test_IsInOrganizationUnitAsync()
        {
            //Act & Assert
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, GetOU("OU11"))).ShouldBe(true);
            (await _userManager.IsInOrganizationUnitAsync(_defaultTenantAdmin, GetOU("OU2"))).ShouldBe(false);
        }

9. Example

View license
[Fact]
        public async Task Should_Remove_User_From_Organization_When_User_Is_Deleted()
        {

            //Arrange
            var user = CreateAndGetTestUser();
            var ou11 = GetOU("OU11");

            await _userManager.AddToOrganizationUnitAsync(user, ou11);
            (await _userManager.IsInOrganizationUnitAsync(user, ou11)).ShouldBe(true);

            //Act
            (await _userManager.DeleteAsync(user)).CheckErrors();

            //Assert
            (await _userManager.IsInOrganizationUnitAsync(user, ou11)).ShouldBe(false);
        }

10. Example

View license
[Theory]
        [InlineData(new object[] { new string[0] })]
        [InlineData(new object[] { new[] { "OU12", "OU21" } })]
        [InlineData(new object[] { new[] { "OU11", "OU12", "OU2" } })]
        public async Task Test_SetOrganizationUnitsAsync(string[] organizationUnitNames)
        {
            //Arrange
            var organizationUnitIds = organizationUnitNames.Select(oun => GetOU(oun).Id).ToArray();

            //Act
            await _userManager.SetOrganizationUnitsAsync(_defaultTenantAdmin, organizationUnitIds);

            //Assert
            UsingDbContext(context =>
            {
                context.UserOrganizationUnits
                    .Count(uou => uou.UserId == _defaultTenantAdmin.Id && organizationUnitIds.Contains(uou.OrganizationUnitId))
                    .ShouldBe(organizationUnitIds.Length);
            });
        }

11. Example

View license
[Fact]
        public async Task Should_Remove_User_From_Organization_When_User_Is_Deleted()
        {

            //Arrange
            var user = CreateAndGetTestUser();
            var ou11 = GetOU("OU11");

            await _userManager.AddToOrganizationUnitAsync(user, ou11);
            (await _userManager.IsInOrganizationUnitAsync(user, ou11)).ShouldBe(true);

            //Act
            (await _userManager.DeleteAsync(user)).CheckErrors();

            //Assert
            (await _userManager.IsInOrganizationUnitAsync(user, ou11)).ShouldBe(false);
        }

12. Example

View license
[Theory]
        [InlineData(new object[] { new string[0] })]
        [InlineData(new object[] { new[] { "OU12", "OU21" } })]
        [InlineData(new object[] { new[] { "OU11", "OU12", "OU2" } })]
        public async Task Test_SetOrganizationUnitsAsync(string[] organizationUnitNames)
        {
            //Arrange
            var organizationUnitIds = organizationUnitNames.Select(oun => GetOU(oun).Id).ToArray();

            //Act
            await _userManager.SetOrganizationUnitsAsync(_defaultTenantAdmin, organizationUnitIds);

            //Assert
            UsingDbContext(context =>
            {
                context.UserOrganizationUnits
                    .Count(uou => uou.UserId == _defaultTenantAdmin.Id && organizationUnitIds.Contains(uou.OrganizationUnitId))
                    .ShouldBe(organizationUnitIds.Length);
            });
        }