<commit_before>$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")

Describe "Get-Role" -Tags "Get-Role" {

	Mock Export-ModuleMember { return $null; }
	
	. "$here\$sut"
	. "$here\Format-ResultAs.ps1"
	. "$here\Get-Tenant.ps1"
	
	$entityPrefix = "Get-Role";
	$usedEntitySets = @("Roles");
	
	Context "Get-Role" {
		
		
		BeforeEach {
			
			$moduleName = 'biz.dfch.PS.Appclusive.Client';
			Remove-Module $moduleName -ErrorAction:SilentlyContinue;
			Import-Module $moduleName;
		
			$svc = Enter-ApcServer;
	
			$name = "{0}-Name-{1}" -f $entityPrefix, [guid]::NewGuid().ToString();
			$value = "value-{0}" -f [guid]::NewGuid().ToString();
			$entityKindId = [biz.dfch.CS.Appclusive.Public.Constants+EntityKindId]::Node.value__;
		}
		
		AfterAll {
			$svc = Enter-ApcServer;
			$entityFilter = "startswith(Name, '{0}')" -f $entityPrefix;

			# Delete Test Data
			foreach ($entitySet in $usedEntitySets)
			{
				$entities = $svc.Core.$entitySet.AddQueryOption('$filter', $entityFilter) | Select;
		 
				foreach ($entity in $entities)
				{
					Remove-ApcEntity -svc $svc -Id $entity.Id -EntitySetName $entitySet -Confirm:$false;
				}
			}
		}
	
		It "Warmup" -Test {
			$true | Should Be $true;
		}

		It "Get-Role-ShouldReturnList" -Test {
			# Arrange
			# N/A
			
			# Act
			$result = Get-Role -svc $svc -ListAvailable;
			
			# Assert
			$result | Should Not Be $null;
			$result -is [Array] | Should Be $true;
			0 -lt $result.Count | Should Be $true;
		}

		It "Get-RoleListAvailableSelectName-ShouldReturnListWithNamesOnly" -Test {
			# Arrange
			# N/A
			
			# Act
			$result = Get-Role -svc $svc -ListAvailable -Select Name;

			# Assert
			$result | Should Not Be $null;
			$result -is [Array] | Should Be $true;
			0 -lt $result.Count | Should Be $true;
			$result[0].Name | Should Not Be $null;
			$result[0].Id | Should Be $null;
		}

		It "Get-RoleFirst-ShouldReturnFirstEntity" -Test {
			# Arrange
			$showFirst = 1;
			
			# Act
			$result = Get-Role -svc $svc -First $showFirst;

			# Assert
			$result | Should Not Be $null;
			$result -is [biz.dfch.CS.Appclusive.Api.Core.Role] | Should Be $true;
		}
		
		It "Get-Role-ShouldReturnEntityById" -Test {
			# Arrange
			$showFirst = 1;
			
			# Act
			$resultFirst = Get-Role -svc $svc -First $showFirst;
			$id = $resultFirst.Id;
			$result = Get-Role -Id $id -svc $svc;

			# Assert
			$result | Should Not Be $null;
			$result | Should Be $resultFirst;
			$result -is [biz.dfch.CS.Appclusive.Api.Core.Role] | Should Be $true;
			$result.id | Should Be $id;
		}
		
		It "Get-Role-ShouldReturnFiveEntities" -Test {
			# Arrange
			$showFirst = 5;
			
			# Act
			$result = Get-Role -svc $svc -First $showFirst;

			# Assert
			$result | Should Not Be $null;
			$showFirst -eq $result.Count | Should Be $true;
			$result[0] -is [biz.dfch.CS.Appclusive.Api.Core.Role] | Should Be $true;
		}

		It "Get-RoleThatDoesNotExist-ShouldReturnNull" -Test {
			# Arrange
			$roleName = 'Role-that-does-not-exist';
			$tid = Get-Tenant -svc $svc -Current;
			
			# Act
			$result = Get-Role -svc $svc -Name $roleName -Tid $tid;

			# Assert
			$result | Should Be $null;
		}
		
		It "Get-RoleThatDoesNotExist-ShouldReturnDefaultValue" -Test {
			# Arrange
			$roleName = 'Role-that-does-not-exist';
			$tid = Get-Tenant -svc $svc -Current;
			$defaultValue = 'MyDefaultValue';
			
			# Act
			$result = Get-Role -svc $svc -Name $roleName -Tid $tid -DefaultValue $defaultValue;

			# Assert
			$result | Should Be $defaultValue;
		}
		
		It "Get-RoleAsXml-ShouldReturnXML" -Test {
			# Arrange
			$showFirst = 1;
			
			# Act<commit_msg>Get-Role.Tests.ps1<commit_after>$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")

Describe "Get-Role" -Tags "Get-Role" {

	Mock Export-ModuleMember { return $null; }
	
	. "$here\$sut"
	. "$here\Format-ResultAs.ps1"
	. "$here\Get-Tenant.ps1"
	
	$entityPrefix = "Get-Role";
	$usedEntitySets = @("Roles");
	
	Context "Get-Role" {
		
		
		BeforeEach {
			
			$moduleName = 'biz.dfch.PS.Appclusive.Client';
			Remove-Module $moduleName -ErrorAction:SilentlyContinue;
			Import-Module $moduleName;
		
			$svc = Enter-ApcServer;
	
			$name = "{0}-Name-{1}" -f $entityPrefix, [guid]::NewGuid().ToString();
			$value = "value-{0}" -f [guid]::NewGuid().ToString();
			$entityKindId = [biz.dfch.CS.Appclusive.Public.Constants+EntityKindId]::Node.value__;
		}
		
		AfterAll {
			$svc = Enter-ApcServer;
			$entityFilter = "startswith(Name, '{0}')" -f $entityPrefix;

			# Delete Test Data
			foreach ($entitySet in $usedEntitySets)
			{
				$entities = $svc.Core.$entitySet.AddQueryOption('$filter', $entityFilter) | Select;
		 
				foreach ($entity in $entities)
				{
					Remove-ApcEntity -svc $svc -Id $entity.Id -EntitySetName $entitySet -Confirm:$false;
				}
			}
		}
	
		It "Warmup" -Test {
			$true | Should Be $true;
		}

		It "Get-Role-ShouldReturnList" -Test {
			# Arrange
			# N/A
			
			# Act
			$result = Get-Role -svc $svc -ListAvailable;
			
			# Assert
			$result | Should Not Be $null;
			$result -is [Array] | Should Be $true;
			0 -lt $result.Count | Should Be $true;
		}

		It "Get-RoleListAvailableSelectName-ShouldReturnListWithNamesOnly" -Test {
			# Arrange
			# N/A
			
			# Act
			$result = Get-Role -svc $svc -ListAvailable -Select Name;

			# Assert
			$result | Should Not Be $null;
			$result -is [Array] | Should Be $true;
			0 -lt $result.Count | Should Be $true;
			$result[0].Name | Should Not Be $null;
			$result[0].Id | Should Be $null;
		}

		It "Get-RoleFirst-ShouldReturnFirstEntity" -Test {
			# Arrange
			$showFirst = 1;
			
			# Act
			$result = Get-Role -svc $svc -First $showFirst;

			# Assert
			$result | Should Not Be $null;
			$result -is [biz.dfch.CS.Appclusive.Api.Core.Role] | Should Be $true;
		}
		
		It "Get-Role-ShouldReturnEntityById" -Test {
			# Arrange
			$showFirst = 1;
			
			# Act
			$resultFirst = Get-Role -svc $svc -First $showFirst;
			$id = $resultFirst.Id;
			$result = Get-Role -Id $id -svc $svc;

			# Assert
			$result | Should Not Be $null;
			$result | Should Be $resultFirst;
			$result -is [biz.dfch.CS.Appclusive.Api.Core.Role] | Should Be $true;
			$result.id | Should Be $id;
		}
		
		It "Get-Role-ShouldReturnFiveEntities" -Test {
			# Arrange
			$showFirst = 5;
			
			# Act
			$result = Get-Role -svc $svc -First $showFirst;

			# Assert
			$result | Should Not Be $null;
			$showFirst -eq $result.Count | Should Be $true;
			$result[0] -is [biz.dfch.CS.Appclusive.Api.Core.Role] | Should Be $true;
		}

		It "Get-RoleThatDoesNotExist-ShouldReturnNull" -Test {
			# Arrange
			$roleName = 'Role-that-does-not-exist';
			$tid = (Get-Tenant -svc $svc -Current).Id;
			
			# Act
			$result = Get-Role -svc $svc -Name $roleName -Tid $tid;

			# Assert
			$result | Should Be $null;
		}
		
		It "Get-RoleThatDoesNotExist-ShouldReturnDefaultValue" -Test {
			# Arrange
			$roleName = 'Role-that-does-not-exist';
			$tid = (Get-Tenant -svc $svc -Current).Id;
			$defaultValue = 'MyDefaultValue';
			
			# Act
			$result = Get-Role -svc $svc -Name $roleName -Tid $tid -DefaultValue $defaultValue;

			# Assert
			$result | Should Be $defaultValue;
		}
		
		It "Get-RoleAsXml-ShouldReturnXML" -Test {
			# Arrange
			$showFirst = 1;
			
			# Act
{'fraction_non_alphanumeric': 0.15268933748814523, 'fraction_numerical': 0.004199972903400623, 'mean_word_length': 2.7895277207392195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2322065', 'n_tokens_mistral': 3270, 'n_tokens_neox': 2713, 'n_words': 621}