add event hub confirm resource examples

This commit is contained in:
Caroline 2023-03-23 12:00:54 -07:00
Родитель 930d150fe3
Коммит ea8186149e
3 изменённых файлов: 178 добавлений и 58 удалений

Просмотреть файл

@ -197,7 +197,7 @@ function Get-ResourceByType {
return Confirm-EventHubConsumerGroup @params
}
"EventHubNamespace" {
return Confirm-EventHubNamespace -NamespaceName $NamespaceName -ResourceGroupName $ResourceGroupName
return Confirm-EventHubNamespace -NamespaceName $ResourceName -ResourceGroupName $ResourceGroupName
}
"KeyVault" {
return Confirm-KeyVault -Name $ResourceName -ResourceGroupName $ResourceGroupName

Просмотреть файл

@ -1,14 +1,57 @@
BeforeAll {
Import-Module Az.InfrastructureTesting
$Script:rgName = 'rg-test'
$Script:nameSpace = 'eventhubnamespace'
$Script:eventHubName = 'eventhub'
$Script:location = 'westus3'
}
Describe 'Verify EventHub' {
BeforeAll {
$Script:noEventHub = 'noeventhub'
}
it 'Should contain an eventhub with the given name - Confirm-AzBPResource' {
#arrange
$params = @{
ResourceType = "EventHub"
ResourceGroupName = $rgName
ResourceName = $eventHubName
NamespaceName = $nameSpace
}
#act
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
it 'Should contain an eventhub with the expected property name - Confirm-AzBPResource' {
#arrange
$params = @{
ResourceType = "EventHub"
ResourceGroupName = $rgName
ResourceName = $eventHubName
NamespaceName = $nameSpace
PropertyKey = 'Name'
PropertyValue = $eventHubName
}
#act
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
it 'Should contain an eventhub with the given name' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
Name = 'eventhubtest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
Name = $eventHubName
}
#act
@ -21,9 +64,9 @@ Describe 'Verify EventHub' {
it 'Should not contain an eventhub with the given name' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
Name = 'eventhubtest2'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
Name = $noEventHub
}
#act
@ -39,9 +82,9 @@ Describe 'Verify EventHub' {
it 'Should contain an EventHub named eventhubtest' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
Name = 'eventhubtest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
Name = $eventHubName
}
#act
@ -54,39 +97,75 @@ Describe 'Verify EventHub' {
it 'Should contain an EventHub named eventhubtest in westus3' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
Name = 'eventhubtest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
Name = $eventHubName
}
#act
$result = Confirm-AzBPEventHub @params
#assert
$result | Should -BeInLocation 'westus3'
$result | Should -BeInLocation $location
}
it 'Should be in a resource group named rg-test' {
it 'Should be in a resource group named $rgName' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
Name = 'eventhubtest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
Name = $eventHubName
}
#act
$result = Confirm-AzBPEventHub @params
#assert
$result | Should -BeInResourceGroup 'rg-test'
$result | Should -BeInResourceGroup $rgName
}
}
Describe 'Verify EventHub Namespace' {
BeforeAll {
$Script:noNameSpace = 'nosamplenamespace'
}
it 'Should contain an eventhub namespace with the given name - Confirm-AzBPResource' {
#arrange
$params = @{
ResourceType = "EventHubNamespace"
ResourceGroupName = $rgName
ResourceName = $nameSpace
}
#act
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
it 'Should contain an eventhub namespace with the expected property name - Confirm-AzBPResource' {
#arrange
$params = @{
ResourceType = "EventHubNamespace"
ResourceGroupName = $rgName
ResourceName = $nameSpace
PropertyKey = 'Name'
PropertyValue = $nameSpace
}
#act
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
it 'Should contain an eventhub namespace with the given name' {
#arrange
$rgName = 'rg-test'
$namespaceName = 'samplenamespace'
$rgName = $rgName
$namespaceName = $nameSpace
#act
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
@ -97,8 +176,8 @@ Describe 'Verify EventHub Namespace' {
it 'Should not contain an eventhub namespace with the given name' {
#arrange
$rgName = 'rg-test'
$namespaceName = 'samplenamespace2'
$rgName = $rgName
$namespaceName = $noNameSpace
#act
# The '-ErrorAction SilentlyContinue' command suppresses all errors.
@ -112,8 +191,8 @@ Describe 'Verify EventHub Namespace' {
it 'Should contain an EventHub Namespace named samplenamespace' {
#arrange
$rgName = 'rg-test'
$namespaceName = 'samplenamespace'
$rgName = $rgName
$namespaceName = $nameSpace
#act
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
@ -124,37 +203,78 @@ Describe 'Verify EventHub Namespace' {
it 'Should contain an EventHub Namespace named samplenamespace in westus3' {
#arrange
$rgName = 'rg-test'
$namespaceName = 'samplenamespace'
$rgName = $rgName
$namespaceName = $nameSpace
#act
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
#assert
$result | Should -BeInLocation 'westus3'
$result | Should -BeInLocation $location
}
it 'Should be in a resource group named rg-test' {
it 'Should be in a resource group named $rgName' {
#arrange
$rgName = 'rg-test'
$namespaceName = 'samplenamespace'
$rgName = $rgName
$namespaceName = $nameSpace
#act
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
#assert
$result | Should -BeInResourceGroup 'rg-test'
$result | Should -BeInResourceGroup $rgName
}
}
Describe 'Verify EventHub Consumer Group' {
BeforeAll {
$Script:consumerGroup = 'eventhubconsumergroup'
$Script:noConsumerGroup = 'noeventhubconsumergroup'
}
it 'Should contain an eventhub consumer group with the given name - Confirm-AzBPResource' {
#arrange
$params = @{
ResourceType = "EventHubConsumerGroup"
ResourceGroupName = $rgName
ResourceName = $consumerGroup
NamespaceName = $nameSpace
EventHubName = $eventHubName
}
#act
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
it 'Should contain an eventhub consumer group with the expected property name - Confirm-AzBPResource' {
#arrange
$params = @{
ResourceType = "EventHubConsumerGroup"
ResourceGroupName = $rgName
ResourceName = $consumerGroup
NamespaceName = $nameSpace
EventHubName = $eventHubName
PropertyKey = 'Name'
PropertyValue = $consumerGroup
}
#act
$result = Confirm-AzBPResource @params
#assert
$result.Success | Should -Be $true
}
it 'Should contain an eventhub consumer group with the given name' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
EventHubName = 'eventhubtest'
Name = 'eventhubconsumergrouptest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
EventHubName = $eventHubName
Name = $consumerGroup
}
#act
@ -167,10 +287,10 @@ Describe 'Verify EventHub Consumer Group' {
it 'Should not contain an eventhub consumer group with the given name' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
EventHubName = 'eventhubtest'
Name = 'eventhubconsumergrouptest2'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
EventHubName = $eventHubName
Name = $noConsumerGroup
}
#act
@ -186,10 +306,10 @@ Describe 'Verify EventHub Consumer Group' {
it 'Should contain an EventHub consumer group named consumergrouptest' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
EventHubName = 'eventhubtest'
Name = 'eventhubconsumergrouptest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
EventHubName = $eventHubName
Name = $consumerGroup
}
#act
@ -202,32 +322,32 @@ Describe 'Verify EventHub Consumer Group' {
it 'Should contain an EventHub consumer group named consumergrouptest in westus3' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
EventHubName = 'eventhubtest'
Name = 'eventhubconsumergrouptest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
EventHubName = $eventHubName
Name = $consumerGroup
}
#act
$result = Confirm-AzBPEventHubConsumerGroup @params
#assert
$result | Should -BeInLocation 'westus3'
$result | Should -BeInLocation $location
}
it 'Should be in a resource group named rg-test' {
it 'Should be in a resource group named $rgName' {
#arrange
$params = @{
ResourceGroupName = 'rg-test'
NamespaceName = 'samplenamespace'
EventHubName = 'eventhubtest'
Name = 'eventhubconsumergrouptest'
ResourceGroupName = $rgName
NamespaceName = $nameSpace
EventHubName = $eventHubName
Name = $consumerGroup
}
#act
$result = Confirm-AzBPEventHubConsumerGroup @params
#assert
$result | Should -BeInResourceGroup 'rg-test'
$result | Should -BeInResourceGroup $rgName
}
}

Просмотреть файл

@ -25,9 +25,9 @@ and `Confirm-AzBPEventHubNamespace` cmdlet.
1. Update `EventHub.Tests.ps1` variables to point to your expected resources:
- `rg-test` -> `your-resource-group-name`
- `eventhubtest` -> `your-eventhub-name`
- `samplenamespace` -> `your-eventhub-namespace-name`
- `eventhubconsumergrouptest` -> `your-eventhub-consumer-group-name`
- `eventhub` -> `your-eventhub-name`
- `eventhubamespace` -> `your-eventhub-namespace-name`
- `eventhubconsumergroup` -> `your-eventhub-consumer-group-name`
1. If using a local copy of `Az.InfrastructureTesting`, replace `Import-Module Az.InfrastructureTesting` with
`Import-Module "../../bin/BenchPress.Azure.psd1"`.