Skip to content

Commit 20a05f6

Browse files
committed
Restored tests to use global properties
* Now that the tests are creating a collection per test instead of using the default global it is safe to use global properties instead of the delegate to modify the properties
1 parent 05c1253 commit 20a05f6

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

src/Ubiquity.Versioning.Build.Tasks.UT/BuildTaskTests.cs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// -----------------------------------------------------------------------
66

77
using System;
8+
using System.Collections.Generic;
89
using System.IO;
910
using System.Runtime.Loader;
1011
using System.Xml.Linq;
@@ -42,12 +43,16 @@ public BuildTaskTests( TestContext ctx )
4243
[DataRow("net8.0")]
4344
public void ValidateRepoAssemblyVersion( string targetFramework)
4445
{
45-
using var collection = new ProjectCollection();
46+
var globalProperties = new Dictionary<string,string>
47+
{
48+
["BuildVersionXml"] = Path.Combine(RepoRoot, "BuildVersion.xml"),
49+
};
50+
51+
using var collection = new ProjectCollection(globalProperties);
4652

4753
var (testProject, props) = CreateTestProjectAndInvokeTestedPackage(
4854
targetFramework,
49-
pc => pc.Property( "BuildVersionXml", Path.Combine(RepoRoot, "BuildVersion.xml")),
50-
collection
55+
projectCollection: collection
5156
);
5257
string? taskAssembly = testProject.ProjectInstance.GetOptionalProperty("_Ubiquity_NET_Versioning_Build_Tasks");
5358
Assert.IsNotNull( taskAssembly, "Task assembly property should contain full path to the task DLL (Not NULL)" );
@@ -89,15 +94,18 @@ public void ValidateRepoAssemblyVersion( string targetFramework)
8994
[DataRow("net8.0")]
9095
public void GoldenPathTest( string targetFramework )
9196
{
92-
using var collection = new ProjectCollection();
97+
var globalProperties = new Dictionary<string,string>
98+
{
99+
["BuildMajor"] = "20",
100+
["BuildMinor"] = "1",
101+
["BuildPatch"] = "4",
102+
["PreReleaseName"] = "alpha",
103+
};
104+
105+
using var collection = new ProjectCollection(globalProperties);
93106
var (testProject, props) = CreateTestProjectAndInvokeTestedPackage(
94107
targetFramework,
95-
pc => pc.PropertyGroup()
96-
.Property("BuildMajor", "20")
97-
.Property("BuildMinor", "1")
98-
.Property("BuildPatch", "4")
99-
.Property("PreReleaseName", "alpha"),
100-
collection
108+
projectCollection: collection
101109
);
102110

103111
// v20.1.4-alpha => 5.44854.3875.59946 [see: https://csemver.org/playground/site/#/]
@@ -157,18 +165,21 @@ public void GoldenPathTest( string targetFramework )
157165
[DataRow("net8.0")]
158166
public void BuildVersionXmlIsUsed( string targetFramework)
159167
{
160-
using var collection = new ProjectCollection();
161168
string buildVersionXml = CreateBuildVersionXml(20, 1, 5);
162169
string buildTime = DateTime.UtcNow.ToString( "o" );
163170
const string buildIndex = "ABCDEF12";
171+
var globalProperties = new Dictionary<string, string>
172+
{
173+
["BuildTime"] = buildTime,
174+
["CiBuildIndex"] = buildIndex,
175+
["BuildVersionXml"] = buildVersionXml
176+
};
177+
178+
using var collection = new ProjectCollection(globalProperties);
164179

165180
var (testProject, props) = CreateTestProjectAndInvokeTestedPackage(
166181
targetFramework,
167-
pc => pc.PropertyGroup()
168-
.Property( "BuildTime", buildTime )
169-
.Property( "CiBuildIndex", buildIndex )
170-
.Property( "BuildVersionXml", buildVersionXml ),
171-
collection
182+
projectCollection: collection
172183
);
173184

174185
// v20.1.5 => 5.44854.3880.52268 [see: https://csemver.org/playground/site/#/]

0 commit comments

Comments
 (0)