testing code display

Test-Code "Solution framework_v*.WSP is installed in solution store" {
  arrange {
    $solutionName = "framework_v*.WSP"
  }
  act {
    $solution = Get-SPSolution $solutionName    # NOTE: mijn Get-SPSolution voor SharePoint 2007 ondersteunt wildcards!
  }
  assert {
    Assert-That { $solution –ne $null }   -FailMessage "Solution `"$solutionName`" not found in solution store"
    Assert-That { $solution.Deployed }    -FailMessage “Solution `"$solutionName`" is not deployed"
  }
}

Test-Code "Feature `"Error Page control adapter`" is activated (at web application scope)" {
  arrange {
    $webAppUrl                      = "http://portal.nl"
    $featureIdentity                = "Feature-ErrorPageControlAdapter"
    $featureIsInstalled             = $false
    $webAppScopedFeatureIsActivated = $false
  }
  act {
    # Get the feature from the list of all installed features in the server farm
    $feature            = Get-SPFeature -Identity $featureIdentity
    $featureIsInstalled = ($feature -ne $null -and $feature.Status -eq "Online")
    if ($featureIsInstalled)
    {
	  $webAppScopedFeatureIsActivated = ((Get-SPFeature -Identity $featureIdentity -WebAppUrl $webAppUrl) -ne $null)
    }
  }
  assert {
    Assert-That { $featureIsInstalled }             -FailMessage "Feature `"$featureIdentity`" is not installed in the farm."
    Assert-That { $webAppScopedFeatureIsActivated } -FailMessage "Feature `"$featureIdentity`" is not activated at webapplication `"$webAppUrl`"."
  }
}

Author: Josh R.

I live in Washington state, I love tall trees and I am a Happiness Engineer at Automattic.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s