-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
when updating from nuget, remove NuGetPackageImportStamp - fixes #1864
- Loading branch information
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module Paket.ProjectFile.UpdateFromNugetSpecs | ||
|
||
open Paket | ||
open NUnit.Framework | ||
open FsUnit | ||
open System.Xml | ||
open System.IO | ||
|
||
let convertAndCompare source expectedResult = | ||
let projectFile = ProjectFile.LoadFromString("Test.csproj", source) | ||
ProjectFile.removeNuGetPackageImportStamp projectFile | ||
let actualResult = Utils.normalizeXml projectFile.Document | ||
let normalizedExpected = | ||
let doc = XmlDocument() | ||
doc.LoadXml(expectedResult) | ||
doc |> Utils.normalizeXml | ||
actualResult |> shouldEqual normalizedExpected | ||
|
||
[<Test>] | ||
let ``should remove NuGetPackageImportStamp and empty PropertyGroup``() = | ||
let projectFile = """<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
</Project>""" | ||
|
||
let expectedResult = """<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
</Project>""" | ||
|
||
convertAndCompare projectFile expectedResult | ||
|
||
[<Test>] | ||
let ``should remove NuGetPackageImportStamp but not PropertyGroup with items``() = | ||
let projectFile = """<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<WarningLevel>4</WarningLevel> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
</PropertyGroup> | ||
</Project>""" | ||
|
||
let expectedResult = """<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
</Project>""" | ||
|
||
convertAndCompare projectFile expectedResult | ||
|
||
let testDataRootPath = Path.Combine(__SOURCE_DIRECTORY__, "TestData") | ||
let TestData: obj[][] = [| | ||
for f in Directory.GetFiles testDataRootPath do | ||
let allText = File.ReadAllText f | ||
if not (allText.Contains "NuGetPackageImportStamp") then | ||
yield [| Path.GetFileName f |] | ||
|] | ||
|
||
|
||
[<Test>] | ||
[<TestCaseSource("TestData")>] | ||
let ``should not modify projects without NuGetPackageImportStamp`` projectFile = | ||
let text = File.ReadAllText (Path.Combine(testDataRootPath, projectFile)) | ||
convertAndCompare text text |