Unit testing virtual networks

Testing a virtual network involves validating successful deployment, the virtual network address range, the subnet address range, the number of subnets, and whether the subnets have been provisioned successfully. The same has been shown in the next script example. This code file is available with the accompanied code file, chapter-6 - listing8.txt:

     Context "virtual network from template deployment" {
It "The virtual network has been provisioned successfully" {
[string]$virtualNetwork.provisioningState | Should Be "Succeeded"
}
It "The address range for virtual network is "10.0.0.0/16" {
[string]$virtualNetwork.addressSpace.addressPrefixes | Should Be "10.0.0.0/16"
}
It "The count of subnets in virtual network is 1" {
[int]$virtualNetwork.subnets.Count | Should Be 1
}
It "The IP address range for subnet is "10.0.0.0/24"{
[string]$virtualNetwork.subnets[0].properties.addressPrefix | Should Be "10.0.0.0/24"
}

It "The subnet has been provisioned successfully" { [string]$virtualNetwork.subnets[0].properties.provisioningState | Should Be "Succeeded"
}
}