-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from FirelyTeam/75-packagecontextinstallpacka…
…gedependency-with-version-null-should-return-the-latest-version Creating package dependency without a version will result in "latest"
- Loading branch information
Showing
5 changed files
with
53 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Firely.Fhir.Packages.Tests | ||
|
@@ -20,54 +21,60 @@ public void ParseReferences() | |
Assert.AreEqual("hl7.fhir.r4.core", reference.Name); | ||
Assert.AreEqual("4.0.1", reference.Version); | ||
} | ||
} | ||
|
||
[TestClass] | ||
public class VersionsTest | ||
{ | ||
[TestMethod] | ||
public void Resolve_PackageDependencyExistsInVersionList_FixedVersionSearchFindsVersion() | ||
public void ParseDependencie() | ||
{ | ||
var target = new Versions(new string[] { "1.0.0", "2.0.0" }); | ||
var dependencie = (PackageDependency)"[email protected]"; | ||
|
||
PackageReference result = target.Resolve(new PackageDependency("SomeName", "1.0.0")); | ||
|
||
Assert.IsTrue(result.Found); | ||
Assert.AreEqual("1.0.0", result.Version); | ||
} | ||
|
||
[TestMethod] | ||
public void Resolve_PackageDependencyExistsInVersionList_RangedVersionSearchFindsVersion() | ||
{ | ||
var target = new Versions(new string[] { "1.0.0", "2.0.0" }); | ||
Assert.AreEqual("hl7.fhir.r4.core", dependencie.Name); | ||
Assert.AreEqual("4.0.1", dependencie.Range); | ||
|
||
PackageReference result = target.Resolve(new PackageDependency("SomeName", "1.x")); | ||
dependencie = "[email protected]"; | ||
|
||
Assert.IsTrue(result.Found); | ||
Assert.AreEqual("1.0.0", result.Version); | ||
Assert.AreEqual("hl7.fhir.r4.core", dependencie.Name); | ||
Assert.AreEqual("4.0.1", dependencie.Range); | ||
} | ||
|
||
[TestMethod] | ||
public void Resolve_PackageDependencyDoesNotExistInVersionList_FixedVersionSearchReturnsNotFound() | ||
public void ParseDependencieWithoutVersion() | ||
{ | ||
var target = new Versions(new string[] { "1.0.0", "2.0.0" }); | ||
var dependencie = (PackageDependency)"hl7.fhir.r4.core"; | ||
|
||
Assert.AreEqual("hl7.fhir.r4.core", dependencie.Name); | ||
Assert.AreEqual("latest", dependencie.Range); | ||
|
||
PackageReference result = target.Resolve(new PackageDependency("SomeName", "3.0.0")); | ||
dependencie = "hl7.fhir.r4.core"; | ||
|
||
Assert.IsFalse(result.Found); | ||
Assert.IsTrue(result.NotFound); | ||
Assert.AreEqual("hl7.fhir.r4.core", dependencie.Name); | ||
Assert.AreEqual("latest", dependencie.Range); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void Resolve_PackageDependencyDoesNotExistInVersionList_RangedVersionSearchReturnsNotFound() | ||
[TestClass] | ||
public class VersionsTest | ||
{ | ||
[DataRow("1.0.0", "1.0.0")] | ||
[DataRow("1.x", "1.0.0")] | ||
[DataRow("latest", "2.0.0")] | ||
[DataRow(null, "2.0.0")] | ||
[DataRow("3.0.0", null)] | ||
[DataRow("3.x", null)] | ||
[DataTestMethod] | ||
public void ResolveVersionTest(string? version, string? versionReturned) | ||
{ | ||
var target = new Versions(new string[] { "1.0.0", "2.0.0" }); | ||
|
||
PackageReference result = target.Resolve(new PackageDependency("SomeName", "3.x")); | ||
PackageReference result = target.Resolve(new PackageDependency("SomeName", version)); | ||
|
||
Assert.IsFalse(result.Found); | ||
Assert.IsTrue(result.NotFound); | ||
} | ||
bool found = versionReturned is not null; | ||
result.Found.Should().Be(found); | ||
result.NotFound.Should().NotBe(found); | ||
|
||
if (found) | ||
{ | ||
result.Version.Should().Be(versionReturned); | ||
} | ||
} | ||
} | ||
} |
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