diff options
author | Jose Perez Rodriguez <joperezr@microsoft.com> | 2016-09-13 01:20:12 +0300 |
---|---|---|
committer | Jose Perez Rodriguez <joperezr@microsoft.com> | 2016-09-13 01:20:12 +0300 |
commit | a1989d82cff273db667638e4836ea7836f5c6eb9 (patch) | |
tree | 24c513224c9c72120a4b9b95c57fe868a97ff690 /src/System.Globalization.Calendars/tests | |
parent | d8bee609fd7b7fa232e4e36c5659514091cd6a3a (diff) | |
parent | 5f43b8637ac49a0304bd55482a009c448eb83a47 (diff) |
Merge remote-tracking branch 'mainrepo/dev/api' into MergeDevApi
Diffstat (limited to 'src/System.Globalization.Calendars/tests')
4 files changed, 146 insertions, 14 deletions
diff --git a/src/System.Globalization.Calendars/tests/Misc/Calendars.netstandard1.7.cs b/src/System.Globalization.Calendars/tests/Misc/Calendars.netstandard1.7.cs new file mode 100644 index 0000000000..ba4253dcde --- /dev/null +++ b/src/System.Globalization.Calendars/tests/Misc/Calendars.netstandard1.7.cs @@ -0,0 +1,95 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Xunit; +using System.Globalization; +using System.Collections.Generic; + +namespace System.Globalization.Tests +{ + + public static class CalendarsMoreTests + { + public static IEnumerable<object[]> Calendars_TestData() + { + // Calendar yearHasLeapMonth CalendarAlgorithmType + yield return new object[] { new ChineseLunisolarCalendar() , 0 , CalendarAlgorithmType.LunisolarCalendar }; + yield return new object[] { new GregorianCalendar() , 0 , CalendarAlgorithmType.SolarCalendar }; + yield return new object[] { new HebrewCalendar() , 5345 , CalendarAlgorithmType.LunisolarCalendar }; + yield return new object[] { new HijriCalendar() , 0 , CalendarAlgorithmType.LunarCalendar }; + yield return new object[] { new JapaneseCalendar() , 0 , CalendarAlgorithmType.SolarCalendar }; + yield return new object[] { new JapaneseLunisolarCalendar() , 0 , CalendarAlgorithmType.LunisolarCalendar }; + yield return new object[] { new JulianCalendar() , 0 , CalendarAlgorithmType.SolarCalendar }; + yield return new object[] { new KoreanCalendar() , 0 , CalendarAlgorithmType.SolarCalendar }; + yield return new object[] { new KoreanLunisolarCalendar() , 0 , CalendarAlgorithmType.LunisolarCalendar }; + yield return new object[] { new PersianCalendar() , 0 , CalendarAlgorithmType.SolarCalendar }; + yield return new object[] { new TaiwanCalendar() , 0 , CalendarAlgorithmType.SolarCalendar }; + yield return new object[] { new TaiwanLunisolarCalendar() , 0 , CalendarAlgorithmType.LunisolarCalendar }; + yield return new object[] { new ThaiBuddhistCalendar() , 0 , CalendarAlgorithmType.SolarCalendar }; + yield return new object[] { new UmAlQuraCalendar() , 0 , CalendarAlgorithmType.LunarCalendar }; + } + + [Theory] + [MemberData(nameof(Calendars_TestData))] + [ActiveIssue(11605, Xunit.PlatformID.AnyUnix)] + [ActiveIssue(11605, Xunit.PlatformID.AnyUnix)] + public static void CloningTest(Calendar calendar, int yearHasLeapMonth, CalendarAlgorithmType algorithmType) + { + Calendar cloned = (Calendar) calendar.Clone(); + Assert.Equal(calendar.GetType(), cloned.GetType()); + } + + [Theory] + [MemberData(nameof(Calendars_TestData))] + [ActiveIssue(11605, Xunit.PlatformID.AnyUnix)] + public static void GetLeapMonthTest(Calendar calendar, int yearHasLeapMonth, CalendarAlgorithmType algorithmType) + { + if (yearHasLeapMonth > 0) + { + Assert.NotEqual(calendar.GetLeapMonth(yearHasLeapMonth), 0); + Assert.Equal(0, calendar.GetLeapMonth(yearHasLeapMonth - 1)); + } + else + Assert.True(calendar.GetLeapMonth(calendar.GetYear(DateTime.Today)) == 0, + "calendar.GetLeapMonth returned wrong value"); + } + + [Theory] + [MemberData(nameof(Calendars_TestData))] + [ActiveIssue(11605, Xunit.PlatformID.AnyUnix)] + public static void ReadOnlyTest(Calendar calendar, int yearHasLeapMonth, CalendarAlgorithmType algorithmType) + { + Assert.False(calendar.IsReadOnly); + var readOnlyCal = Calendar.ReadOnly(calendar); + Assert.True(readOnlyCal.IsReadOnly, "expect readOnlyCal.IsReadOnly returns true"); + var colnedCal = (Calendar) readOnlyCal.Clone(); + Assert.False(colnedCal.IsReadOnly, "expect colnedCal.IsReadOnly returns false"); + } + + [Theory] + [MemberData(nameof(Calendars_TestData))] + [ActiveIssue(11605, Xunit.PlatformID.AnyUnix)] + public static void AlgorithmTypeTest(Calendar calendar, int yearHasLeapMonth, CalendarAlgorithmType algorithmType) + { + Assert.Equal(calendar.AlgorithmType, algorithmType); + } + + [Fact] + [ActiveIssue(11605, Xunit.PlatformID.AnyUnix)] + public static void CalendarErasTest() + { + Assert.Equal(1, ChineseLunisolarCalendar.ChineseEra); + Assert.Equal(1, GregorianCalendar.ADEra); + Assert.Equal(1, JapaneseLunisolarCalendar.JapaneseEra); + Assert.Equal(1, HebrewCalendar.HebrewEra); + Assert.Equal(1, HijriCalendar.HijriEra); + Assert.Equal(1, JulianCalendar.JulianEra); + Assert.Equal(1, KoreanCalendar.KoreanEra); + Assert.Equal(1, KoreanLunisolarCalendar.GregorianEra); + Assert.Equal(1, PersianCalendar.PersianEra); + Assert.Equal(1, ThaiBuddhistCalendar.ThaiBuddhistEra); + Assert.Equal(1, UmAlQuraCalendar.UmAlQuraEra); + } + } +} diff --git a/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.builds b/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.builds index a2a1a9905b..549d46d988 100644 --- a/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.builds +++ b/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.builds @@ -4,6 +4,10 @@ <ItemGroup> <Project Include="System.Globalization.Calendars.Tests.csproj"/> <Project Include="System.Globalization.Calendars.Tests.csproj"> + <TargetGroup>netstandard1.7</TargetGroup> + <TestTFMs>netcoreapp1.1</TestTFMs> + </Project> + <Project Include="System.Globalization.Calendars.Tests.csproj"> <TestTFMs>netcore50;net46</TestTFMs> <OSGroup>Windows_NT</OSGroup> </Project> diff --git a/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj b/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj index 1bddbc4021..6c0a3b70e8 100644 --- a/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj +++ b/src/System.Globalization.Calendars/tests/System.Globalization.Calendars.Tests.csproj @@ -8,8 +8,14 @@ <OutputType>Library</OutputType> <AssemblyName>System.Globalization.Calendars.Tests</AssemblyName> <RootNamespace>System.Globalization.Calendars.Tests</RootNamespace> - <NugetTargetMoniker>.NETStandard,Version=v1.3</NugetTargetMoniker> + <NugetTargetMoniker Condition="'$(TargetGroup)'=='netstandard1.7' AND '$(NugetTargetMoniker)'==''">.NETStandard,Version=v1.7</NugetTargetMoniker> + <NugetTargetMoniker Condition="'$(NugetTargetMoniker)'==''">.NETStandard,Version=v1.3</NugetTargetMoniker> </PropertyGroup> + <ItemGroup Condition="'$(TargetGroup)'=='netstandard1.7'"> + <TestNugetTargetMoniker Include="$(NugetTargetMoniker)"> + <Folder>netcoreapp1.1</Folder> + </TestNugetTargetMoniker> + </ItemGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" /> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'" /> @@ -121,6 +127,11 @@ <Link>Common\System\PlatformDetection.cs</Link> </Compile> </ItemGroup> + + <ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.7'"> + <Compile Include="Misc\Calendars.netstandard1.7.cs" /> + </ItemGroup> + <ItemGroup> <None Include="project.json" /> </ItemGroup> @@ -141,6 +152,10 @@ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <Targets>Build;DebugSymbolsProjectOutputGroup</Targets> </ProjectReference> + <!-- ToDo: Remove this reference to the live package of System.Globalization once prerelease gets updated again --> + <ProjectReference Include="..\..\System.Runtime\pkg\System.Runtime.pkgproj"> + <Name>System.Runtime</Name> + </ProjectReference> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> </Project>
\ No newline at end of file diff --git a/src/System.Globalization.Calendars/tests/project.json b/src/System.Globalization.Calendars/tests/project.json index 16ea846394..9e1f0247bf 100644 --- a/src/System.Globalization.Calendars/tests/project.json +++ b/src/System.Globalization.Calendars/tests/project.json @@ -1,23 +1,25 @@ { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.2-beta-24512-01", - "System.Globalization": "4.3.0-beta-24512-01", - "System.Globalization.Calendars": "4.3.0-beta-24512-01", - "System.IO.FileSystem": "4.3.0-beta-24512-01", - "System.Linq.Expressions": "4.3.0-beta-24512-01", - "System.ObjectModel": "4.3.0-beta-24512-01", - "System.Runtime.Extensions": "4.3.0-beta-24512-01", - "System.Text.RegularExpressions": "4.3.0-beta-24512-01", - "System.Threading.Tasks": "4.3.0-beta-24512-01", - "Microsoft.xunit.netcore.extensions": "1.0.0-prerelease-00807-03", - "Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00807-03", + "Microsoft.NETCore.Platforms": "4.3.0-beta-devapi-24512-01", + "System.Globalization": "4.3.0-beta-devapi-24512-01", + "System.Globalization.Calendars": "4.3.0-beta-devapi-24512-01", + "System.IO.FileSystem": "4.3.0-beta-devapi-24512-01", + "System.Linq.Expressions": "4.3.0-beta-devapi-24512-01", + "System.ObjectModel": "4.3.0-beta-devapi-24512-01", + "System.Runtime.Extensions": "4.3.0-beta-devapi-24512-01", + "System.Text.RegularExpressions": "4.3.0-beta-devapi-24512-01", + "System.Threading.Tasks": "4.3.0-beta-devapi-24512-01", + "System.Text.Encoding": "4.3.0-beta-devapi-24512-01", + "Microsoft.xunit.netcore.extensions": "1.0.0-prerelease-00731-01", + "Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00731-01", "test-runtime": { "target": "project", "exclude": "compile" } }, "frameworks": { - "netstandard1.3": {} + "netstandard1.3": {}, + "netstandard1.7": {} }, "supports": { "coreFx.Test.netcore50": {}, @@ -25,6 +27,22 @@ "coreFx.Test.net46": {}, "coreFx.Test.net461": {}, "coreFx.Test.net462": {}, - "coreFx.Test.net463": {} + "coreFx.Test.net463": {}, + "coreFx.Test.netcoreapp1.1-ns17": { + "netstandard1.7": [ + "win7-x86", + "win7-x64", + "win10-arm64", + "osx.10.10-x64", + "centos.7-x64", + "debian.8-x64", + "rhel.7-x64", + "ubuntu.14.04-x64", + "ubuntu.16.04-x64", + "fedora.23-x64", + "linux-x64", + "opensuse.13.2-x64" + ] + } } } |