public void GetNearest_NullItemInArray_ThrowsArgumentException() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var targetFramework = new FrameworkName(".NETCoreApp,Version=v3.1"); var goodFrameworks = new[] { new FrameworkName(".NETStandard,Version=v2.0") }; var nullFrameworks = new FrameworkName[] { null }; // Act & Assert Assert.Throws <ArgumentException>(() => target.GetNearest(targetFramework, goodFrameworks, nullFrameworks)); Assert.Throws <ArgumentException>(() => target.GetNearest(targetFramework, nullFrameworks, goodFrameworks)); }
public void GetNearest_NullItemInEnumerable_ThrowsArgumentException() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var net5 = new VsNuGetFramework(".NETCoreApp,Version=v5.0", targetPlatformMoniker: null, targetPlatformMinVersion: null); var netstandard2_0 = new VsNuGetFramework(".NETStandard,Version=v2.0", targetPlatformMoniker: null, targetPlatformMinVersion: null); var goodFrameworks = new IVsNuGetFramework[] { netstandard2_0 }; var nullFrameworks = new IVsNuGetFramework[] { null }; // Act & Asset Assert.Throws <ArgumentException>(() => target.GetNearest(targetFramework: net5, frameworks: nullFrameworks)); Assert.Throws <ArgumentException>(() => target.GetNearest(targetFramework: net5, fallbackTargetFrameworks: goodFrameworks, frameworks: nullFrameworks)); Assert.Throws <ArgumentException>(() => target.GetNearest(targetFramework: net5, fallbackTargetFrameworks: nullFrameworks, frameworks: goodFrameworks)); }
public void VsFrameworkCompatibility_GetNearestRejectsNullFrameworks() { // Arrange var target = new VsFrameworkCompatibility(); var targetFramework = new FrameworkName(".NETFramework,Version=v4.5"); FrameworkName[] frameworks = null; // Act & Assert Assert.Throws <ArgumentNullException>(() => target.GetNearest(targetFramework, frameworks)); }
public void GetNearest_NullArguments_ThrowsArgumentNullException() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var targetFramework = new FrameworkName(".NETCoreApp,Version=v3.1"); FrameworkName[] fallbackTargetFrameworks = new[] { new FrameworkName(".NETFramework,Version=v4.7.2") }; var frameworks = new[] { new FrameworkName(".NETCoreApp,Version=v3.0"), new FrameworkName(".NETStandard,Version=v2.0"), }; // Act & Assert Assert.Throws <ArgumentNullException>(() => target.GetNearest(null, fallbackTargetFrameworks, frameworks)); Assert.Throws <ArgumentNullException>(() => target.GetNearest(targetFramework, null, frameworks)); Assert.Throws <ArgumentNullException>(() => target.GetNearest(targetFramework, fallbackTargetFrameworks, null)); }
public void GetNearest_InvalidFramework_ThrowsArgumentException() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var invalidFramework = new VsNuGetFramework("Invalid,Version=vWrong", targetPlatformMoniker: null, targetPlatformMinVersion: null); var netstandard2_0 = new VsNuGetFramework(".NETStandard,Version=v2.0", targetPlatformMoniker: null, targetPlatformMinVersion: null); var frameworks = new IVsNuGetFramework[] { netstandard2_0 }; // Act & Assert Assert.Throws <ArgumentException>(() => target.GetNearest(invalidFramework, frameworks)); }
public void VsFrameworkCompatibility_GetNearestRejectsNullTargetFramework() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); FrameworkName targetFramework = null; var frameworks = new[] { new FrameworkName(".NETFramework,Version=v4.5.1"), new FrameworkName(".NETFramework,Version=v4.5.2"), }; // Act & Assert Assert.Throws <ArgumentNullException>(() => target.GetNearest(targetFramework, frameworks)); }
public void GetNearest_NoCompatibleFramework_ReturnsNull() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var net5 = new VsNuGetFramework(".NETCoreApp,Version=v5.0", targetPlatformMoniker: null, targetPlatformMinVersion: null); var net472 = new VsNuGetFramework(".NETFramework,Version=v4.7.2", targetPlatformMoniker: null, targetPlatformMinVersion: null); var frameworks = new IVsNuGetFramework[] { net472 }; // Act var actual = target.GetNearest(net5, frameworks); // Assert Assert.Null(actual); }
public void GetNearest_WithCompatibleFramework_Succeeds() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var net5 = new VsNuGetFramework(".NETCoreApp,Version=v5.0", targetPlatformMoniker: null, targetPlatformMinVersion: null); var net472 = new VsNuGetFramework(".NETFramework,Version=v4.7.2", targetPlatformMoniker: null, targetPlatformMinVersion: null); var netcoreapp31 = new VsNuGetFramework(".NETCoreApp,Version=v3.1", targetPlatformMoniker: null, targetPlatformMinVersion: null); var frameworks = new IVsNuGetFramework[] { net472, netcoreapp31 }; // Act var actual = target.GetNearest(net5, frameworks); // Assert Assert.Equal(netcoreapp31, actual); }
public void VsFrameworkCompatibility_GetNearestNet5EraFails() { // Arrange var target = new VsFrameworkCompatibility(); var targetFramework = new FrameworkName(".NETCoreApp,Version=v5.0"); var frameworks = new[] { new FrameworkName(".NETCoreApp,Version=v4.0"), new FrameworkName(".NETCoreApp,Version=v5.0.0"), new FrameworkName(".NETCoreApp,Version=v5.1.0"), new FrameworkName(".NETCoreApp,Version=v6.0"), }; // Act Assert.Throws <System.ArgumentException>(() => target.GetNearest(targetFramework, frameworks)); }
public void IVsFrameworkCompatibility3_GetNearest_WithFallbackTfm_Succeeds() { // Arrange var target = new VsFrameworkCompatibility(); var net5 = new VsNuGetFramework(".NETCoreApp,Version=v5.0", targetPlatformMoniker: null, targetPlatformMinVersion: null); var net472 = new VsNuGetFramework(".NETFramework,Version=v4.7.2", targetPlatformMoniker: null, targetPlatformMinVersion: null); var fallbackFrameworks = new IVsNuGetFramework[] { net472 }; var frameworks = new IVsNuGetFramework[] { net472 }; // Act var actual = target.GetNearest(net5, fallbackFrameworks, frameworks); // Assert Assert.Equal(net472, actual); }
public void VsFrameworkCompatibility_GetNearestWithNoneCompatible() { // Arrange var target = new VsFrameworkCompatibility(); var targetFramework = new FrameworkName(".NETFramework,Version=v4.5"); var frameworks = new[] { new FrameworkName(".NETFramework,Version=v4.5.1"), new FrameworkName(".NETFramework,Version=v4.5.2"), }; // Act var actual = target.GetNearest(targetFramework, frameworks); // Assert Assert.Null(actual); }
public void VsFrameworkCompatibility_GetNearestWithMultipleCompatible() { // Arrange var target = new VsFrameworkCompatibility(); var targetFramework = new FrameworkName(".NETFramework,Version=v4.5.1"); var frameworks = new[] { new FrameworkName(".NETFramework,Version=v3.5"), new FrameworkName(".NETFramework,Version=v4.0"), new FrameworkName(".NETFramework,Version=v4.5"), new FrameworkName(".NETFramework,Version=v4.5.2"), }; // Act var actual = target.GetNearest(targetFramework, frameworks); // Assert Assert.Equal(".NETFramework,Version=v4.5", actual.ToString()); }
public void VsFrameworkCompatibility_GetNearestWithWithEmptyFallbackList() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var targetFramework = new FrameworkName(".NETFramework,Version=v4.5.1"); var fallbackTargetFrameworks = new FrameworkName[0]; var frameworks = new[] { new FrameworkName(".NETFramework,Version=v3.5"), new FrameworkName(".NETFramework,Version=v4.0"), new FrameworkName(".NETFramework,Version=v4.5"), new FrameworkName(".NETFramework,Version=v4.5.2"), }; // Act var actual = target.GetNearest(targetFramework, frameworks); // Assert Assert.Equal(".NETFramework,Version=v4.5", actual.ToString()); }
public void GetNearest_WithIncompatibleFallback_ReturnsNull() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var targetFramework = new FrameworkName(".NETFramework,Version=v4.5"); var fallbackTargetFrameworks = new[] { new FrameworkName(".NETFramework,Version=v4.5.2") }; var frameworks = new[] { new FrameworkName(".NETFramework,Version=v4.6"), new FrameworkName(".NETFramework,Version=v4.6.1"), }; // Act var actual = target.GetNearest(targetFramework, fallbackTargetFrameworks, frameworks); // Assert Assert.Null(actual); }
public void GetNearest_WithCompatibleFallback_Succeeds() { // Arrange var target = new VsFrameworkCompatibility(_telemetryProvider.Object); var targetFramework = new FrameworkName(".NETFramework,Version=v4.5"); var fallbackTargetFrameworks = new[] { new FrameworkName(".NETFramework,Version=v4.5.2") }; var frameworks = new[] { new FrameworkName(".NETFramework,Version=v4.5.1"), new FrameworkName(".NETFramework,Version=v4.6.1"), }; // Act var actual = target.GetNearest(targetFramework, fallbackTargetFrameworks, frameworks); // Assert Assert.Equal(".NETFramework,Version=v4.5.1", actual.ToString()); }