-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
42,928 additions
and
0 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
IcgSoftware.RecurrenceRuleToText.UnitTest/IcgSoftware.RecurrenceRuleToText.UnitTest.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http:https://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{296145A7-60CE-46F7-98D8-5714F95DA753}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>IcgSoftware.RecurrenceRuleToText.UnitTest</RootNamespace> | ||
<AssemblyName>IcgSoftware.RecurrenceRuleToText.UnitTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> | ||
<IsCodedUITest>False</IsCodedUITest> | ||
<TestProjectType>UnitTest</TestProjectType> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Ical.Net, Version=4.1.8.0, Culture=neutral, PublicKeyToken=65c0446cd019ea53, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Ical.Net.4.1.11\lib\net46\Ical.Net.dll</HintPath> | ||
</Reference> | ||
<Reference Include="IcgSoftware.IntToOrdinalNumber, Version=0.9.3.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\IcgSoftware.IntToOrdinalNumber.0.9.3\lib\netstandard2.0\IcgSoftware.IntToOrdinalNumber.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NodaTime, Version=2.0.2.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NodaTime.2.0.2\lib\net45\NodaTime.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Reflection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\System.Reflection.4.1.0\lib\net462\System.Reflection.dll</HintPath> | ||
<Private>True</Private> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\System.Reflection.TypeExtensions.4.1.0\lib\net462\System.Reflection.TypeExtensions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\System.Runtime.Serialization.Primitives.4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll</HintPath> | ||
<Private>True</Private> | ||
<Private>True</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="RRuleTextBuilderTestBase.cs" /> | ||
<Compile Include="RRuleTextBuilderTestDe.cs" /> | ||
<Compile Include="RRuleTextBuilderTestEn.cs" /> | ||
<Compile Include="RRuleTextBuilderTestEs.cs" /> | ||
<Compile Include="RRuleTextBuilderTestFr.cs" /> | ||
<Compile Include="RRuleTextBuilderTestIv.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\IcgSoftware.RecurrenceRuleToText\IcgSoftware.RecurrenceRuleToText.csproj"> | ||
<Project>{d3251755-af52-4ec6-aa5a-2f2f92346d07}</Project> | ||
<Name>IcgSoftware.RecurrenceRuleToText</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http:https://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" /> | ||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" /> | ||
</Target> | ||
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" /> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
IcgSoftware.RecurrenceRuleToText.UnitTest/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("IcgSoftware.RecurrenceRuleToText.UnitTest")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("IcgSoftware.RecurrenceRuleToText.UnitTest")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
[assembly: ComVisible(false)] | ||
|
||
[assembly: Guid("296145a7-60ce-46f7-98d8-5714f95da753")] | ||
|
||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
49 changes: 49 additions & 0 deletions
49
IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Globalization; | ||
using Ical.Net.DataTypes; | ||
|
||
namespace IcgSoftware.RecurrenceRuleToText.UnitTest | ||
{ | ||
abstract public class RRuleTextBuilderTestBase | ||
{ | ||
|
||
abstract protected void ToTextTest(string rRuleString, string readableString); | ||
|
||
protected class RRuleTextBuilderTestHelper | ||
{ | ||
private RecurrencePattern recurrencePattern; | ||
public string RRuleString; | ||
public string ReadableString; | ||
public string ReadableResult; | ||
public string RecreatedRRuleString; | ||
|
||
public RRuleTextBuilderTestHelper(string rRuleString, string readableString) | ||
{ | ||
RRuleString = rRuleString; | ||
ReadableString = readableString; | ||
string rRuleStringC = RRuleTextBuilder.GetRRuleStringCorrection(rRuleString); | ||
recurrencePattern = new RecurrencePattern(rRuleStringC); | ||
RecreatedRRuleString = recurrencePattern.ToString(); | ||
ReadableResult = recurrencePattern.ToText(); | ||
} | ||
|
||
public RRuleTextBuilderTestHelper(string rRuleString, string readableString, string culture) | ||
{ | ||
|
||
RRuleString = rRuleString; | ||
ReadableString = readableString; | ||
string rRuleStringC = RRuleTextBuilder.GetRRuleStringCorrection(rRuleString); | ||
recurrencePattern = new RecurrencePattern(rRuleStringC); | ||
RecreatedRRuleString = recurrencePattern.ToString(); | ||
ReadableResult = recurrencePattern.ToText(new CultureInfo(culture)); | ||
} | ||
|
||
public bool Result { get => ReadableString == ReadableResult; } | ||
public string ResultMessage { get => $"{ReadableResult} (missed: {ReadableString})"; } | ||
|
||
} | ||
|
||
} | ||
|
||
} |
112 changes: 112 additions & 0 deletions
112
IcgSoftware.RecurrenceRuleToText.UnitTest/RRuleTextBuilderTestDe.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace IcgSoftware.RecurrenceRuleToText.UnitTest | ||
{ | ||
[TestClass] | ||
public class RRuleTextBuilderTestDe : RRuleTextBuilderTestBase | ||
{ | ||
protected override void ToTextTest(string rRuleString, string readableString) | ||
{ | ||
Debug.WriteLine("DE: " + readableString); | ||
var rRuleTextBuilderTest = new RRuleTextBuilderTestHelper(rRuleString, readableString, "de"); | ||
Assert.IsTrue(rRuleTextBuilderTest.Result, rRuleTextBuilderTest.ResultMessage); | ||
} | ||
|
||
[TestMethod] | ||
public void LastNumeral() | ||
{ | ||
ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-1MO", "monatlich am letzten Montag"); | ||
ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-2MO", "monatlich am vorletzten Montag"); | ||
ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-3FR", "monatlich am drittletzten Freitag"); | ||
ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-4SU", "monatlich am viertletzten Sonntag"); | ||
} | ||
|
||
[TestMethod] | ||
public void JavaRruleParser() | ||
{ | ||
//aditosoftware tests | ||
|
||
ToTextTest("FREQ=DAILY;INTERVAL=5", "alle 5 Tage"); | ||
ToTextTest("FREQ=WEEKLY;INTERVAL=5", "alle 5 Wochen"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=5", "alle 5 Monate"); | ||
ToTextTest("FREQ=YEARLY;INTERVAL=5", "alle 5 Jahre"); | ||
|
||
ToTextTest("FREQ=DAILY;INTERVAL=1", "täglich"); //"jeden Tag" | ||
ToTextTest("FREQ=WEEKLY;INTERVAL=1", "wöchentlich"); //"jede Woche" | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=1", "monatlich"); //"jeden Monat" | ||
ToTextTest("FREQ=YEARLY;INTERVAL=1", "jährlich"); //"jedes Jahr" | ||
|
||
ToTextTest("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU", "wöchentlich am Montag, Dienstag"); | ||
ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU", "alle 2 Wochen am Montag, Dienstag"); | ||
ToTextTest("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU,WE,SA", "alle 2 Wochen am Montag, Dienstag, Mittwoch, Sonnabend"); | ||
|
||
ToTextTest("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=5", "monatlich am 5."); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=15", "monatlich am 15."); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYMONTHDAY=15", "alle 2 Monate am 15."); | ||
|
||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=-1", "alle 2 Monate am letzten Montag"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=1", "alle 2 Monate am ersten Montag"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=SA;BYSETPOS=3", "alle 2 Monate am dritten Sonnabend"); | ||
|
||
ToTextTest("FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1", "jährlich am 01. Januar"); | ||
ToTextTest("FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=5", "jährlich am 05. April"); | ||
|
||
ToTextTest("FREQ=YEARLY;BYDAY=SU;BYSETPOS=1;BYMONTH=1", "jährlich am ersten Sonntag im Januar"); | ||
ToTextTest("FREQ=YEARLY;BYDAY=WE;BYSETPOS=-1;BYMONTH=4", "jährlich am letzten Mittwoch im April"); | ||
|
||
ToTextTest("FREQ=DAILY;INTERVAL=1;COUNT=2", "täglich insgesamt 2 Mal"); | ||
ToTextTest("FREQ=WEEKLY;INTERVAL=1;COUNT=1", "wöchentlich"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=1;UNTIL=20181023T220000Z", "monatlich bis zum 23. Oktober 2018"); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void Custom() | ||
{ | ||
ToTextTest("FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=MO;BYDAY=FR,TH,MO,TU,WE", "jeden Wochentag insgesamt 30 Mal"); | ||
ToTextTest("FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=MO;BYDAY=FR,TU,WE,TH", "wöchentlich am Dienstag, Mittwoch, Donnerstag, Freitag insgesamt 30 Mal"); | ||
ToTextTest("FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=SU;BYDAY=FR,TU,WE,TH,SU", "wöchentlich am Sonntag, Dienstag, Mittwoch, Donnerstag, Freitag insgesamt 30 Mal"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=1", "alle 2 Monate am ersten Freitag"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=2", "alle 2 Monate am zweiten Freitag"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=3", "alle 2 Monate am dritten Freitag"); | ||
ToTextTest("FREQ=MONTHLY;INTERVAL=2;BYDAY=FR;BYSETPOS=4", "alle 2 Monate am vierten Freitag"); | ||
} | ||
|
||
[TestMethod] | ||
public void RruleJsDemoApp() | ||
{ | ||
//https://github.com/jakubroztocil/rrule | ||
|
||
//Options | ||
ToTextTest("RRULE:FREQ=WEEKLY;COUNT=30;INTERVAL=1;WKST=MO", "wöchentlich insgesamt 30 Mal"); | ||
|
||
//RRule string | ||
ToTextTest("RRULE:FREQ=WEEKLY;BYDAY=MO,WE", "wöchentlich am Montag, Mittwoch"); //Schöner wäre am Montag und Mittwoch | ||
ToTextTest("RRULE:FREQ=MONTHLY;BYMONTHDAY=10,15;COUNT=20", "monatlich am 10. und 15. insgesamt 20 Mal"); | ||
ToTextTest("RRULE:FREQ=DAILY;INTERVAL=3;COUNT=10", "alle 3 Tage insgesamt 10 Mal"); | ||
ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-2FR;COUNT=7", "monatlich am vorletzten Freitag insgesamt 7 Mal"); | ||
|
||
|
||
//Text input | ||
ToTextTest("RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "jeden Wochentag"); | ||
ToTextTest("RRULE:INTERVAL=2;FREQ=WEEKLY;BYDAY=TU", "alle 2 Wochen am Dienstag"); | ||
ToTextTest("RRULE:FREQ=WEEKLY;BYDAY=MO,WE", "wöchentlich am Montag, Mittwoch"); | ||
ToTextTest("RRULE:FREQ=MONTHLY;BYDAY=-2FR;COUNT=7", "monatlich am vorletzten Freitag insgesamt 7 Mal"); | ||
ToTextTest("RRULE:INTERVAL=6;FREQ=MONTHLY", "alle 6 Monate"); | ||
|
||
//extra | ||
ToTextTest("FREQ=MONTHLY;BYMONTHDAY=10,15,21;COUNT=20", "monatlich am 10., 15. und 21. insgesamt 20 Mal"); | ||
ToTextTest("FREQ=MONTHLY;BYDAY=2FR;COUNT=7", "monatlich am 2. Freitag insgesamt 7 Mal"); | ||
ToTextTest("FREQ=WEEKLY;BYDAY=SU,SA,MO,TU,WE,TH,FR", "jeden Tag"); | ||
ToTextTest("RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU", "alle 2 Wochen am Dienstag"); | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.