public void TestParseWithStandardProfileString() { // Arrange & Act var profileCollection = new NetPortableProfileCollection(); var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NetCore, Version=4.5"), new FrameworkName("Silverlight, Version=3.0"), new FrameworkName("WindowsPhone, Version=7.1"), }); profileCollection.Add(profile1); profileCollection.Add(profile2); NetPortableProfileTable.Profiles = profileCollection; var profile = NetPortableProfile.Parse("Profile2"); // Assert Assert.Equal(3, profile.SupportedFrameworks.Count); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NetCore, Version=4.5"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=3.0"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1"))); }
public void TestParseWithCustomProfileString5WithOptionalFrameworkAndTreatedAsOptional() { // Arrange var collection = new NetPortableProfileCollection(); var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), }, new[] { new FrameworkName("MonoTouch, Version=0.0"), new FrameworkName("MonoAndroid, Version=2.0"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NetCore, Version=4.5"), new FrameworkName("Silverlight, Version=3.0"), new FrameworkName("WindowsPhone, Version=7.1"), }); collection.Add(profile1); collection.Add(profile2); var table = new NetPortableProfileTable(collection); // Act // Default value of second parameter treatOptionalFrameworksAsSupportedFrameworks is false var profile = NetPortableProfile.Parse( table, "net45+sl40+wp71+MonoTouch+MonoAndroid20"); // Assert Assert.Equal(3, profile.SupportedFrameworks.Count); Assert.Equal(2, profile.OptionalFrameworks.Count); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1"))); Assert.True(profile.OptionalFrameworks.Contains(new FrameworkName("MonoTouch, Version=0.0"))); Assert.True(profile.OptionalFrameworks.Contains(new FrameworkName("MonoAndroid, Version=2.0"))); }
public void TestParseWithCustomProfileString4WithDifferentOrderingOfFrameworks() { // Arrange var collection = new NetPortableProfileCollection(); var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), }, new[] { new FrameworkName("MonoTouch, Version=0.0"), new FrameworkName("MonoAndroid, Version=2.0"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NetCore, Version=4.5"), new FrameworkName("Silverlight, Version=3.0"), new FrameworkName("WindowsPhone, Version=7.1"), }); collection.Add(profile1); collection.Add(profile2); var table = new NetPortableProfileTable(collection); // Act var profile = NetPortableProfile.Parse( table, "net45+sl40+MonoTouch+wp71+MonoAndroid20"); // Assert Assert.Equal(5, profile.SupportedFrameworks.Count); Assert.Equal(0, profile.OptionalFrameworks.Count); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("MonoTouch, Version=0.0"))); }
public void TestParseWithCustomProfileString6WithOptionalFrameworkAndTreatedAsSupported() { // Arrange & Act var profileCollection = new NetPortableProfileCollection(); var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), }, new[] { new FrameworkName("MonoTouch, Version=0.0"), new FrameworkName("MonoAndroid, Version=2.0"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NetCore, Version=4.5"), new FrameworkName("Silverlight, Version=3.0"), new FrameworkName("WindowsPhone, Version=7.1"), }); profileCollection.Add(profile1); profileCollection.Add(profile2); NetPortableProfileTable.Profiles = profileCollection; var profile = NetPortableProfile.Parse("net45+sl40+wp71+MonoTouch+MonoAndroid20", treatOptionalFrameworksAsSupportedFrameworks: true); // Assert Assert.Equal(5, profile.SupportedFrameworks.Count); Assert.Equal(0, profile.OptionalFrameworks.Count); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName(".NETFramework, Version=4.5"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("Silverlight, Version=4.0"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("WindowsPhone, Version=7.1"))); Assert.True(profile.SupportedFrameworks.Contains(new FrameworkName("MonoTouch, Version=0.0"))); }
public void AddPackageReferenceThrowsWhenNoTargetFrameworkIsCompatibleWithPortableProject() { // Arrange var portableCollection = new NetPortableProfileCollection(); portableCollection.Add(new NetPortableProfile("Profile104", new [] { VersionUtility.ParseFrameworkName("net45"), VersionUtility.ParseFrameworkName("sl5")})); NetPortableProfileTable.Profiles = portableCollection; var sourceRepository = new MockPackageRepository(); var projectSystem = new MockProjectSystem(new FrameworkName(".NETPortable, Version=1.0, Profile=Profile104")); var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository()); IPackage packageA = PackageUtility.CreatePackage("A", "1.0", new[] { "silverlight4\\a.txt"}); sourceRepository.AddPackage(packageA); // Act ExceptionAssert.Throws<InvalidOperationException>( () => projectManager.AddPackageReference("A"), "Could not install package 'A 1.0'. You are trying to install this package into a project that targets 'portable-net45+sl50', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."); }
public void TestIsCompatibleWithPortableProfile11WithMonoProjectWithVersionLesserThanInstalledProfile() { // Arrange var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), new FrameworkName("Windows, Version=8.0"), }, new[] { new FrameworkName("MonoTouch, Version=1.0"), new FrameworkName("MonoAndroid, Version=2.0"), new FrameworkName("MonoMac, Version=1.0"), }); NetPortableProfileCollection profileCollection = new NetPortableProfileCollection(); profileCollection.Add(profile1); var packageProfile = new NetPortableProfile( "ProfileXXX", new[] { new FrameworkName(".NETFramework, Version=4.0"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.0"), new FrameworkName("Windows, Version=8.0"), }); var projectProfile = new FrameworkName("MonoAndroid, Version=1.0"); NetPortableProfileTable.Profiles = profileCollection; // Act & Assert Assert.False(packageProfile.IsCompatibleWith(projectProfile)); }
private NetPortableProfileCollection BuildProfileCollection() { var profileCollection = new NetPortableProfileCollection(); var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NetCore, Version=4.5"), new FrameworkName("Silverlight, Version=3.0"), new FrameworkName("WindowsPhone, Version=7.1"), }); var profile3 = new NetPortableProfile( "Profile3", new[] { new FrameworkName(".NetCore, Version=4.5"), new FrameworkName(".NETFramework, Version=2.0"), }); var profile4 = new NetPortableProfile( "Profile4", new[] { new FrameworkName("Silverlight, Version=2.0"), new FrameworkName("Silverlight, Version=3.0, Profile=WindowsPhone"), }); profileCollection.Add(profile1); profileCollection.Add(profile2); profileCollection.Add(profile3); profileCollection.Add(profile4); return profileCollection; }
public void TestGetCompatibilityBetweenPortableLibraryAndNonPortableLibraryForMono(string projectFrameworkName, string packageTargetFrameworkName, long expectedScore) { // Arrange var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), new FrameworkName("Windows, Version=8.0"), }, new[] { new FrameworkName("MonoTouch, Version=1.0"), new FrameworkName("MonoAndroid, Version=1.0"), new FrameworkName("MonoMac, Version=1.0"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("WindowsPhone, Version=8.0"), new FrameworkName("Windows, Version=8.0"), }, new[] { new FrameworkName("MonoTouch, Version=1.0"), new FrameworkName("MonoAndroid, Version=1.0"), }); NetPortableProfileCollection profileCollection = new NetPortableProfileCollection(); profileCollection.Add(profile1); profileCollection.Add(profile2); NetPortableProfileTable.Profiles = profileCollection; // Arrange var framework = VersionUtility.ParseFrameworkName(projectFrameworkName); var targetFramework = VersionUtility.ParseFrameworkName(packageTargetFrameworkName); // Act long score = VersionUtility.GetCompatibilityBetweenPortableLibraryAndNonPortableLibrary(framework, targetFramework); // Assert Assert.Equal(expectedScore, score); }
public void TestGetCompatibilityBetweenPortableLibraryAndPortableLibraryWithPreLoadedPackageProfile(string frameworkName, string targetFrameworkName, int expectedScore) { var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.0"), new FrameworkName("Silverlight, Version=4.0"), }, new[] { new FrameworkName("MonoTouch, Version=0.0"), new FrameworkName("MonoAndroid, Version=0.0"), }); NetPortableProfileCollection profileCollection = new NetPortableProfileCollection(); profileCollection.Add(profile1); NetPortableProfileTable.Profiles = profileCollection; // Arrange var framework = VersionUtility.ParseFrameworkName(frameworkName); var targetFramework = VersionUtility.ParseFrameworkName(targetFrameworkName); // Act int score = VersionUtility.GetCompatibilityBetweenPortableLibraryAndPortableLibrary(framework, targetFramework); // Assert Assert.Equal(expectedScore, score); }
public void TestGetShortNameForPortableXamarinFrameworks(string frameworkIdentifier, string expectedShortName) { // Arrange var profileCollection = new NetPortableProfileCollection(); var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Xamarin.Mac, Version=1.0"), new FrameworkName("Xamarin.iOS, Version=1.0"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NETFramework, Version=4.0"), new FrameworkName(".NetCore, Version=4.5"), new FrameworkName("Xamarin.PlayStation3, Version=1.0"), new FrameworkName("Xamarin.PlayStation4, Version=1.0"), new FrameworkName("Xamarin.PlayStationVita, Version=1.0"), }); var profile3 = new NetPortableProfile( "Profile3", new[] { new FrameworkName(".NETFramework, Version=4.0"), new FrameworkName("Xamarin.Xbox360, Version=1.0"), new FrameworkName("Xamarin.XboxOne, Version=1.0"), }); profileCollection.Add(profile1); profileCollection.Add(profile2); profileCollection.Add(profile3); var portableProfileTable = new NetPortableProfileTable(profileCollection); var framework = new FrameworkName(frameworkIdentifier); // Act string shortName = VersionUtility.GetShortFrameworkName(framework, portableProfileTable); // Assert Assert.Equal(expectedShortName, shortName); }
public void TestIsCompatibleWithPortableProfile12WithMonoProjectWithMultipleInstalledProfileHavingMonoOfDifferentVersions() { // Arrange var profile1 = new NetPortableProfile( "Profile1", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), new FrameworkName("Windows, Version=8.0"), }, new[] { new FrameworkName("MonoTouch, Version=1.0"), new FrameworkName("MonoAndroid, Version=3.0"), new FrameworkName("MonoMac, Version=1.0"), }); var profile2 = new NetPortableProfile( "Profile2", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.1"), new FrameworkName("Windows, Version=8.0"), }, new[] { new FrameworkName("MonoAndroid, Version=1.0"), new FrameworkName("MonoMac, Version=1.0"), }); var profile3 = new NetPortableProfile( "Profile3", new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=4.5"), }, new[] { new FrameworkName("MonoAndroid, Version=3.0"), }); NetPortableProfileCollection profileCollection = new NetPortableProfileCollection(); profileCollection.Add(profile1); profileCollection.Add(profile2); profileCollection.Add(profile3); var packageProfile = new NetPortableProfile( "ProfileXXX", new[] { new FrameworkName(".NETFramework, Version=4.0"), new FrameworkName("Silverlight, Version=4.0"), new FrameworkName("WindowsPhone, Version=7.0"), new FrameworkName("Windows, Version=8.0"), }); var projectProfile = new FrameworkName("MonoAndroid, Version=2.0"); NetPortableProfileTable.Profiles = profileCollection; // Act & Assert Assert.True(packageProfile.IsCompatibleWith(projectProfile)); }