Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.9.0" />
<PackageReference Include="NJsonSchema" Version="9.10.70" />
<PackageReference Include="NJsonSchema" Version="9.10.71" />
</ItemGroup>

</Project>
68 changes: 68 additions & 0 deletions test/common/package/package.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

$moduleRootFilePath = Split-Path -Path $PSScriptRoot -Parent

# Identify the repository root path of the resource module
$repoRootPath = (Resolve-Path -LiteralPath (Join-path $moduleRootFilePath "../..")).ProviderPath

Import-Module "$repoRootPath/tools/releaseTools.psm1"

Describe 'Common Tests - Package Reference' -Tag 'CI' {
BeforeAll {
$testCases = @()
Get-NewOfficalPackage -IncludeAll | ForEach-Object {
$testCases += @{
CsProj = $_.CsProj
PackageName = $_.PackageName
CsProjVersion = $_.CsProjVersion
NuGetRevision = $_.NuGetRevision
NuGetVersion = $_.NuGetVersion
}
}
}

# This test should always be enabled
It "<CsProj> reference to <PackageName> <CsProjVersion> should not need to be updated by a revision" -TestCases $testCases {
param(
[string]
$CsProj,

[string]
$PackageName,

[string]
$CsProjVersion,

[string]
$NuGetRevision,

[string]
$NuGetVersion
)

$NuGetRevision | Should -BeExactly $CsProjVersion
}

# This test should be enabled when we are developing
It "<CsProj> reference to <PackageName> <CsProjVersion> should not need to be updated by a new version" -TestCases $testCases {
param(
[string]
$CsProj,

[string]
$PackageName,

[string]
$CsProjVersion,

[string]
$NuGetRevision,

[string]
$NuGetVersion
)

$NuGetVersion | Should -BeExactly $CsProjVersion
}
}
101 changes: 101 additions & 0 deletions tools/Xml/Xml.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Adds an attribute to a XmlElement
function New-XmlAttribute
{
param(
[Parameter(Mandatory)]
[string]$Name,
[Parameter(Mandatory)]
[object]$Value,
[Parameter(Mandatory)]
[System.Xml.XmlElement]$Element,
[Parameter(Mandatory)]
[System.Xml.XmlDocument]$XmlDoc
)

$attribute = $XmlDoc.CreateAttribute($Name)
$attribute.Value = $value
$null = $Element.Attributes.Append($attribute)
}

# Adds an XmlElement to an XmlNode
# Returns the new Element
function New-XmlElement
{
param(
[Parameter(Mandatory)]
[string]$LocalName,
[Parameter(Mandatory)]
[System.Xml.XmlDocument]$XmlDoc,
[Parameter(Mandatory)]
[System.Xml.XmlNode]$Node,
[Switch]$PassThru,
[string]$NamespaceUri
)

if($NamespaceUri)
{
$newElement = $XmlDoc.CreateElement($LocalName, $NamespaceUri)
}
else
{
$newElement = $XmlDoc.CreateElement($LocalName)
}

$null = $Node.AppendChild($newElement)
if($PassThru.IsPresent)
{
return $newElement
}
}

# Removes an XmlElement and it's parent if it is empty
function Remove-XmlElement
{
param(
[Parameter(Mandatory)]
[System.Xml.XmlElement]$Element,
[Switch]$RemoveEmptyParents
)

$parentNode = $Element.ParentNode
$null = $parentNode.RemoveChild($Element)
if(!$parentNode.HasChildNodes -and $RemoveEmptyParent.IsPresent)
{
Remove-XmlElement -Element $parentNode -RemoveEmptyParents
}
}

# Get a node by XPath
# Returns null if the node is not found
function Get-XmlNodeByXPath
{
param(
[Parameter(Mandatory)]
[System.Xml.XmlDocument]
$XmlDoc,
[System.Xml.XmlNamespaceManager]
$XmlNsManager,
[Parameter(Mandatory)]
[string]
$XPath
)

if($XmlNsManager)
{
return $XmlDoc.SelectSingleNode($XPath,$XmlNsManager)
}
else
{
return $XmlDoc.SelectSingleNode($XPath)
}
}

Export-ModuleMember -Function @(
'Get-XmlNodeByXPath'
'Remove-XmlElement'
'New-XmlElement'
'New-XmlAttribute'
)
1 change: 1 addition & 0 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ function Invoke-AppveyorFinish
}
catch {
Write-Host -Foreground Red $_
Write-Host -Foreground Red $_.ScriptStackTrace
throw $_
}
}
Loading