Skip to content

Commit a8b818a

Browse files
committed
Bugfixes, samples and unit tests.
1 parent 74379c8 commit a8b818a

File tree

13 files changed

+356
-8
lines changed

13 files changed

+356
-8
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{9016CAEE-52CA-4FAC-BBED-B5D859026144}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>PointerPlace.Scheduler.Samples</RootNamespace>
11+
<AssemblyName>PointerPlace.Scheduler.Samples</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="Program.cs" />
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<None Include="App.config" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<ProjectReference Include="..\PointerPlace.Scheduler\PointerPlace.Scheduler.csproj">
52+
<Project>{cb717645-1eab-407f-a98e-0777758410ba}</Project>
53+
<Name>PointerPlace.Scheduler</Name>
54+
</ProjectReference>
55+
</ItemGroup>
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
58+
Other similar extension points exist, see Microsoft.Common.targets.
59+
<Target Name="BeforeBuild">
60+
</Target>
61+
<Target Name="AfterBuild">
62+
</Target>
63+
-->
64+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace PointerPlace.Scheduler.Samples
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
14+
// Example 1
15+
Schedule schedule = ScheduleParser.ParseSchedule("*/15 0-6/2 * * MON-FRI");
16+
DateTime example1 = Scheduler.GetNext(schedule);
17+
Console.WriteLine(String.Format("Example 1: {0}", example1));
18+
19+
// Example 2
20+
DateTime example2 = Scheduler.GetNext("*/7 * * * *");
21+
Console.WriteLine(String.Format("Example 2: {0}", example2));
22+
23+
// Pause and exit
24+
Console.WriteLine("Press [Enter] to exit");
25+
Console.ReadLine();
26+
27+
}
28+
}
29+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("PointerPlace.Scheduler.Samples")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("PointerPlace.Scheduler.Samples")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("4ed13b49-2fcc-4cc1-8255-a4c4a4b3f2a6")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{C2794601-D470-4E4A-BA9F-086E66B8ABE1}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>PointerPlace.Scheduler.Test</RootNamespace>
10+
<AssemblyName>PointerPlace.Scheduler.Test</AssemblyName>
11+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
</ItemGroup>
40+
<Choose>
41+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
42+
<ItemGroup>
43+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
44+
</ItemGroup>
45+
</When>
46+
<Otherwise>
47+
<ItemGroup>
48+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
49+
</ItemGroup>
50+
</Otherwise>
51+
</Choose>
52+
<ItemGroup>
53+
<Compile Include="ScheduleTests.cs" />
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<ProjectReference Include="..\PointerPlace.Scheduler\PointerPlace.Scheduler.csproj">
58+
<Project>{cb717645-1eab-407f-a98e-0777758410ba}</Project>
59+
<Name>PointerPlace.Scheduler</Name>
60+
</ProjectReference>
61+
</ItemGroup>
62+
<Choose>
63+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
64+
<ItemGroup>
65+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
66+
<Private>False</Private>
67+
</Reference>
68+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
69+
<Private>False</Private>
70+
</Reference>
71+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
72+
<Private>False</Private>
73+
</Reference>
74+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
75+
<Private>False</Private>
76+
</Reference>
77+
</ItemGroup>
78+
</When>
79+
</Choose>
80+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
81+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
83+
Other similar extension points exist, see Microsoft.Common.targets.
84+
<Target Name="BeforeBuild">
85+
</Target>
86+
<Target Name="AfterBuild">
87+
</Target>
88+
-->
89+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("PointerPlace.Scheduler.Test")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("PointerPlace.Scheduler.Test")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("dc634dae-9341-4448-bcd7-3160a1aaebcd")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System.Diagnostics;
4+
5+
namespace PointerPlace.Scheduler.Test
6+
{
7+
[TestClass]
8+
public class ScheduleTests
9+
{
10+
11+
[TestMethod]
12+
public void TestHourRollover()
13+
{
14+
var point = new DateTime(2014, 11, 22, 13, 52, 37);
15+
16+
point = Scheduler.GetNext("*/15 * * * *", point);
17+
18+
Assert.AreEqual(2014, point.Year);
19+
Assert.AreEqual(11, point.Month);
20+
Assert.AreEqual(22, point.Day);
21+
Assert.AreEqual(14, point.Hour);
22+
Assert.AreEqual(0, point.Minute);
23+
Assert.AreEqual(0, point.Second);
24+
Assert.AreEqual(0, point.Millisecond);
25+
}
26+
27+
[TestMethod]
28+
public void TestDayRollover()
29+
{
30+
var point = new DateTime(2014, 11, 22, 20, 52, 37);
31+
32+
point = Scheduler.GetNext("* */8 * * *", point);
33+
34+
Assert.AreEqual(2014, point.Year);
35+
Assert.AreEqual(11, point.Month);
36+
Assert.AreEqual(23, point.Day);
37+
Assert.AreEqual(0, point.Hour);
38+
Assert.AreEqual(0, point.Minute);
39+
Assert.AreEqual(0, point.Second);
40+
Assert.AreEqual(0, point.Millisecond);
41+
}
42+
43+
[TestMethod]
44+
public void TestMonthRollover()
45+
{
46+
var point = new DateTime(2014, 11, 29, 20, 52, 37);
47+
48+
point = Scheduler.GetNext("* * */7 * *", point);
49+
50+
Assert.AreEqual(2014, point.Year);
51+
Assert.AreEqual(12, point.Month);
52+
Assert.AreEqual(7, point.Day);
53+
Assert.AreEqual(0, point.Hour);
54+
Assert.AreEqual(0, point.Minute);
55+
Assert.AreEqual(0, point.Second);
56+
Assert.AreEqual(0, point.Millisecond);
57+
}
58+
59+
[TestMethod]
60+
public void TestYearRollover()
61+
{
62+
var point = new DateTime(2014, 11, 29, 20, 52, 37);
63+
64+
point = Scheduler.GetNext("* * * */5 *", point);
65+
66+
Assert.AreEqual(2015, point.Year);
67+
Assert.AreEqual(5, point.Month);
68+
Assert.AreEqual(1, point.Day);
69+
Assert.AreEqual(0, point.Hour);
70+
Assert.AreEqual(0, point.Minute);
71+
Assert.AreEqual(0, point.Second);
72+
Assert.AreEqual(0, point.Millisecond);
73+
}
74+
75+
}
76+
}

PointerPlace.Scheduler/PointerPlace.Scheduler.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ VisualStudioVersion = 12.0.31101.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointerPlace.Scheduler", "PointerPlace.Scheduler\PointerPlace.Scheduler.csproj", "{CB717645-1EAB-407F-A98E-0777758410BA}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointerPlace.Scheduler.Test", "PointerPlace.Scheduler.Test\PointerPlace.Scheduler.Test.csproj", "{C2794601-D470-4E4A-BA9F-086E66B8ABE1}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PointerPlace.Scheduler.Samples", "PointerPlace.Scheduler.Samples\PointerPlace.Scheduler.Samples.csproj", "{9016CAEE-52CA-4FAC-BBED-B5D859026144}"
11+
EndProject
812
Global
913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1014
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +19,14 @@ Global
1519
{CB717645-1EAB-407F-A98E-0777758410BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
1620
{CB717645-1EAB-407F-A98E-0777758410BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
1721
{CB717645-1EAB-407F-A98E-0777758410BA}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{C2794601-D470-4E4A-BA9F-086E66B8ABE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{C2794601-D470-4E4A-BA9F-086E66B8ABE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{C2794601-D470-4E4A-BA9F-086E66B8ABE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{C2794601-D470-4E4A-BA9F-086E66B8ABE1}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{9016CAEE-52CA-4FAC-BBED-B5D859026144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{9016CAEE-52CA-4FAC-BBED-B5D859026144}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{9016CAEE-52CA-4FAC-BBED-B5D859026144}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{9016CAEE-52CA-4FAC-BBED-B5D859026144}.Release|Any CPU.Build.0 = Release|Any CPU
1830
EndGlobalSection
1931
GlobalSection(SolutionProperties) = preSolution
2032
HideSolutionNode = FALSE

PointerPlace.Scheduler/PointerPlace.Scheduler/Matchers/MinuteMatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public override bool Increment()
7676
var nextMatch = NextMatch();
7777
if (nextMatch != -1)
7878
{
79-
Point.AdvanceMinute(nextMatch - Point.Minute);
79+
Point.AdvanceMinute(nextMatch);
8080
return true;
8181
}
8282
else

PointerPlace.Scheduler/PointerPlace.Scheduler/Matchers/MonthMatcher.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public override bool Matches()
6767
// is no valid next value, -1 is returned.
6868
public override int NextMatch()
6969
{
70-
// TODO, VERIFY MONTH OBOB
71-
return NextMatch(ValidMonths, Point.Month + 1);
70+
return NextMatch(ValidMonths, Point.Month);
7271
}
7372

7473
// Tries to increment the internal PointInTime to its next valid value, returns true if successfull, false otherwise.
@@ -77,7 +76,7 @@ public override bool Increment()
7776
var nextMatch = NextMatch();
7877
if (nextMatch != -1)
7978
{
80-
Point.AdvanceMonth(nextMatch - Point.Month);
79+
Point.AdvanceMonth(nextMatch);
8180
return true;
8281
}
8382
else

0 commit comments

Comments
 (0)