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 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 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);
        }
Ejemplo n.º 5
0
        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);
        }