Skip to content

Commit

Permalink
Fixing and adding test coverage for preview issue between requirement…
Browse files Browse the repository at this point in the history
… divisions
  • Loading branch information
sfoslund committed Jan 22, 2020
1 parent bfdb454 commit 0f8d01e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,10 @@ public override int GetHashCode()
}

public abstract Bundle ToBundle(BundleArch arch, string uninstallCommand, string displayName);

public SemanticVersion GetVersionWithoutTags()
{
return new SemanticVersion(this.Major, this.Minor, this.SemVer.Patch);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ private static (IDictionary<IEnumerable<Bundle>, string>, IEnumerable<Bundle>) A
var dividedBundles = new Dictionary<IEnumerable<Bundle>, string>();
foreach (var (division, explaination) in WindowsVersionDivisionsToExplaination)
{
var bundlesInRange = bundleList.Where(bundle => bundle.Version is SdkVersion && division.Item1 <= bundle.Version.SemVer && bundle.Version.SemVer < division.Item2);
var bundlesInRange = bundleList.Where(bundle => bundle.Version is SdkVersion &&
division.Item1 <= bundle.Version.GetVersionWithoutTags() && bundle.Version.GetVersionWithoutTags() < division.Item2);
bundleList = bundleList.Except(bundlesInRange);
if (bundlesInRange.Count() > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,37 @@ internal void TestUninstallableStringsCorrectManySDKs()
strings.Count.Should().Be(bundles.Count);

var expectedProtected = new string[]{ "3.0.100", "2.0.4" };
AssertRequirementStringsCorrect(bundles, strings, expectedProtected);
}

[Fact]
internal void TestUninstallableStringsCorrectAcrossRequirementDivisions()
{
var bundles = new List<Bundle>
{
new Bundle<SdkVersion>(new SdkVersion("2.0.0"), BundleArch.X64, string.Empty, "2.0.0"),
new Bundle<SdkVersion>(new SdkVersion("2.0.0-preview-0"), BundleArch.X64, string.Empty, "2.0.0-preview-0"),
new Bundle<SdkVersion>(new SdkVersion("2.0.0-preview-1"), BundleArch.X64, string.Empty, "2.0.0-preview-1")
};

var strings = VisualStudioSafeVersionsExtractor.GetReasonRequiredStrings(bundles);
var expectedProtected = new string[] { "2.0.0" };
AssertRequirementStringsCorrect(bundles, strings, expectedProtected);
}

private void AssertRequirementStringsCorrect(List<Bundle> bundles, Dictionary<Bundle, string> bundleStringPairs, string[] expectedProtected)
{
bundleStringPairs.Count.Should().Be(bundles.Count);

var expectedUninstallable = bundles.Select(bundle => bundle.DisplayName)
.Except(expectedProtected);

strings.Where(pair => pair.Key.Version is SdkVersion)
bundleStringPairs.Where(pair => pair.Key.Version is SdkVersion)
.Where(pair => string.IsNullOrEmpty(pair.Value))
.Select(pair => pair.Key.DisplayName)
.Should().BeEquivalentTo(expectedUninstallable);
strings.Where(pair => !string.IsNullOrEmpty(pair.Value))

bundleStringPairs.Where(pair => !string.IsNullOrEmpty(pair.Value))
.Select(pair => pair.Key.DisplayName)
.Should().BeEquivalentTo(expectedProtected);
}
Expand Down

0 comments on commit 0f8d01e

Please sign in to comment.