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

function Stop-Pester()
{
	[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
	PARAM
	(
		$message = "EMERGENCY: Script cannot continue."
	)
	
	$msg = $message;
	$e = New-CustomErrorRecord -msg $msg -cat OperationStopped -o $msg;
	$PSCmdlet.ThrowTerminatingError($e);
}

Describe "ManagementUri.Tests" -Tags "ManagementUri.Tests" {

	Mock Export-ModuleMember { return $null; }
	
	. "$here\$sut"
	
	Context "#CLOUDTCL-1882-ManagementUriTests" {
		
		BeforeEach {
			$moduleName = 'biz.dfch.PS.Appclusive.Client';
			Remove-Module $moduleName -ErrorAction:SilentlyContinue;
			Import-Module $moduleName;
			$svc = Enter-ApcServer;
		}
		
		It "TestName" -Test {
			# Arrange
			
			
			# Act
			
			
			# Assert	
			
			
		}
	}
}

#
# Copyright 2016 d-fens GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");<commit_msg>*created test: create, get and delete managementUri<commit_after># includes tests for CLOUDTCL-2204

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

function Stop-Pester()
{
	[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
	PARAM
	(
		$message = "EMERGENCY: Script cannot continue."
	)
	
	$msg = $message;
	$e = New-CustomErrorRecord -msg $msg -cat OperationStopped -o $msg;
	$PSCmdlet.ThrowTerminatingError($e);
}

Describe "ManagementUri.Tests" -Tags "ManagementUri.Tests" {
	
	Mock Export-ModuleMember { return $null; }
	
	. "$here\$sut"
	
	$entityPrefix = "TestItem-";
	$usedEntitySets = @("ManagementCredentials", "ManagementUris");
	
	Context "#CLOUDTCL-2204-ManagementUriTests" {
		
		BeforeEach {
			$moduleName = 'biz.dfch.PS.Appclusive.Client';
			Remove-Module $moduleName -ErrorAction:SilentlyContinue;
			Import-Module $moduleName;
			$svc = Enter-Appclusive;
		}
		
		AfterEach {
			$svc = Enter-Appclusive;
			$entityFilter = "startswith(Name, '{0}')" -f $entityPrefix;

			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 "ManagementUri-CreateGetAndDelete-Succeeds" -Test {
			# Arrange
			$uriName = $entityPrefix + "ManagementUri-{0}" -f [guid]::NewGuid().ToString();
			$uriDescription = "test description";
			$value = '{ "protocol": "http", "hostname": "172.16.31.10", "port": "8080"}';
			$type = "json";
			
			# Act - create management uri
			Push-ApcChangeTracker -Svc $svc;
			$managementUri = New-ApcManagementUri -svc $svc -Name $uriName -Description $uriDescription -Value $value -Type $type;
			Pop-ApcChangeTracker -Svc $svc;
			
			#Act - get management uri
			Push-ApcChangeTracker -Svc $svc;
			$loadedManagementUri = Get-ApcManagementUri -svc $svc -Id $managementUri.Id;
			Pop-ApcChangeTracker -Svc $svc;
			
			#Act - delete management uri
			Push-ApcChangeTracker -Svc $svc;
			$null = Remove-ApcEntity -svc $svc -Id $managementUri.Id -EntitySetName "ManagementUris" -Confirm:$false;;
			Pop-ApcChangeTracker -Svc $svc;
			
			# Act - get deleted management uri
			Push-ApcChangeTracker -Svc $svc;
			$deletedManagementUri = Get-ApcManagementUri -svc $svc -Id $managementUri.Id;
			Pop-ApcChangeTracker -Svc $svc;
			
			# Assert
			$managementUri | Should Not Be $null;
			$managementUri.Id | Should Not Be 0;
			$managementUri.Name | Should Be $uriName;
			$managementUri.Description | Should Be $uriDescription;
			$managementUri.Value | Should Be $value;
			$managementUri.Type | Should Be $type;
			
			$loadedManagementUri | Should Not Be $null;
			$loadedManagementUri.Id | Should  Be $managementUri.Id;
			
			$deletedManagementUri | Should Be $null;
		}
		<#
		
		
		$credentialName = $entityPrefix + "ManagementCredential-{0}" -f [guid]::NewGuid().ToString();
		$username = "Username-{0}" -f [guid]::NewGuid().ToString();
		$password = "<PASSWORD>}" -f [guid]::NewGuid().ToString();
			
		# Act - create management credential object
		$managementCredential = New-ApcManagementCredential -svc $svc -Name $credentialName -Username $username -Password $password;
			
		
		It "ManagementUri-ExpandManagementCredential-ReturnsManagementCredential" -Test {
			# Arrange
			$credentialName = $entityPrefix + "ManagementCredential-{0}" -f [guid]::NewGuid().ToString();
			$username = "Username-{0}" -f [guid]::NewGuid().ToString();
			$password = "Password-{0}" -f [guid]::NewGuid().ToString();
			$uriName = $entityPrefix + "ManagementUri-{0}" -f [guid]::NewGuid().ToString();
			
			# Act - create management credential object
			$managementCredential = New-ApcManagementCredential -svc $svc -Name $credentialName -Username $username -Password $password;
			
			# Act
			$managementUri = New-ApcManagementUri -svc $svc -Name $uriName;
			$result = New-ApcManagementUri -svc $svc -Id $resultFirst.Id -ExpandManagementCredential;

			# Assert
		   	Get-ManagementCredential;
		   	$result | Should Not Be $null;
		   	$result.GetType().Name | Should Be 'ManagementCredential';
		}#>
	}
}

#
# Copyright 2016 d-fens GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
{'fraction_non_alphanumeric': 0.14, 'fraction_numerical': 0.008440366972477064, 'mean_word_length': 3.893177737881508, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1176153', 'n_tokens_mistral': 2075, 'n_tokens_neox': 1780, 'n_words': 400}