Skip to content

Commit

Permalink
feat: refactor pacakges (#17)
Browse files Browse the repository at this point in the history
Use GitHub actions

BREAKING CHANGE: drop deprecated framworks
  • Loading branch information
viceice committed Nov 22, 2021
1 parent b65a827 commit 0926b8f
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 242 deletions.
44 changes: 0 additions & 44 deletions .appveyor.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,35 @@
name: build

on:
push:
branches:
- main
- 'renovate/**'
pull_request:


concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
35 changes: 19 additions & 16 deletions .vscode/tasks.json
@@ -1,17 +1,20 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [ "NCrontab.Advanced" ],
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
}
]
}
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"command": "dotnet",
"args": [],
"tasks": [
{
"label": "build",
"type": "shell",
"command": "dotnet",
"args": ["build", "NCrontab.Advanced"],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Build on GitHub actions
- Drop deprecated frameworks

## [2.0.0] - 2019-01-16
### Added
- Changes from [Joe Coutcher](https://github.com/jcoutch/NCrontab-Advanced) v1.3.15.
Expand Down
85 changes: 42 additions & 43 deletions NCrontab.Advanced.Tests/CronInstanceTests.cs
Expand Up @@ -6,14 +6,14 @@
//
#endregion

using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NCrontab.Advanced.Enumerations;
using NCrontab.Advanced.Exceptions;
using NCrontab.Advanced.Tests.Extensions;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

namespace NCrontab.Advanced.Tests
{
Expand Down Expand Up @@ -65,43 +65,43 @@ public void InvalidPatternCount()
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * * * * *", CronStringFormat.WithSecondsAndYears));
}

[TestMethod]
public void OutOfBoundsValues()
{
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("-1 * * * * *", CronStringFormat.WithSeconds));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("60 * * * * *", CronStringFormat.WithSeconds));
[TestMethod]
public void OutOfBoundsValues()
{
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("-1 * * * * *", CronStringFormat.WithSeconds));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("60 * * * * *", CronStringFormat.WithSeconds));

Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * * 0", CronStringFormat.WithYears));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * * 10000", CronStringFormat.WithYears));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * * 0", CronStringFormat.WithYears));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * * 10000", CronStringFormat.WithYears));

Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("-1 * * * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("60 * * * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("-1 * * * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("60 * * * *", CronStringFormat.Default));

Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* -1 * * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* 24 * * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* -1 * * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* 24 * * *", CronStringFormat.Default));

Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * 0 * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * 32 * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * 0 * *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * 32 * *", CronStringFormat.Default));

Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * 0 *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * 13 *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * 0 *", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * 13 *", CronStringFormat.Default));

Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * -1", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * 8", CronStringFormat.Default));
}
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * -1", CronStringFormat.Default));
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse("* * * * 8", CronStringFormat.Default));
}

[TestMethod]
public void SundayProcessesCorrectly()
{
var tests = new[]
{
new { startTime = "01/01/2016 00:00:00", inputString = "0 0 * * 0", nextOccurence = "03/01/2016 00:00:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2016 00:00:00", inputString = "0 0 * * 7", nextOccurence = "03/01/2016 00:00:00", cronStringFormat = CronStringFormat.Default },
};
[TestMethod]
public void SundayProcessesCorrectly()
{
var tests = new[]
{
new { startTime = "01/01/2016 00:00:00", inputString = "0 0 * * 0", nextOccurence = "03/01/2016 00:00:00", cronStringFormat = CronStringFormat.Default },
new { startTime = "01/01/2016 00:00:00", inputString = "0 0 * * 7", nextOccurence = "03/01/2016 00:00:00", cronStringFormat = CronStringFormat.Default },
};

foreach (var test in tests)
CronCall(test.startTime, test.inputString, test.nextOccurence, test.cronStringFormat);
}
foreach (var test in tests)
CronCall(test.startTime, test.inputString, test.nextOccurence, test.cronStringFormat);
}

[TestMethod]
public void ThirtyFirstWeekdayForMonthsWithLessThanThirtyDaysProcessesCorrectly()
Expand Down Expand Up @@ -131,13 +131,13 @@ public void Formatting()
{
var tests = new[] {
new { inputString = "* 1-2,3 * * *" , outputString = "* 1-2,3 * * *" , cronStringFormat = CronStringFormat.Default },
new { inputString = "* * * */2 *" , outputString = "* * * */2 *" , cronStringFormat = CronStringFormat.Default },
new { inputString = "10-40/15 * * * *" , outputString = "10-40/15 * * * *" , cronStringFormat = CronStringFormat.Default },
new { inputString = "* * * Mar,Jan,Aug Fri,Mon-Tue" , outputString = "* * * 3,1,8 5,1-2" , cronStringFormat = CronStringFormat.Default },
new { inputString = "1 * 1-2,3 * * *" , outputString = "1 * 1-2,3 * * *" , cronStringFormat = CronStringFormat.WithSeconds },
new { inputString = "22 * * * */2 *" , outputString = "22 * * * */2 *" , cronStringFormat = CronStringFormat.WithSeconds },
new { inputString = "33 10-40/15 * * * *" , outputString = "33 10-40/15 * * * *" , cronStringFormat = CronStringFormat.WithSeconds },
new { inputString = "55 * * * Mar,Jan,Aug Fri,Mon-Tue", outputString = "55 * * * 3,1,8 5,1-2" , cronStringFormat = CronStringFormat.WithSeconds },
new { inputString = "* * * */2 *" , outputString = "* * * */2 *" , cronStringFormat = CronStringFormat.Default },
new { inputString = "10-40/15 * * * *" , outputString = "10-40/15 * * * *" , cronStringFormat = CronStringFormat.Default },
new { inputString = "* * * Mar,Jan,Aug Fri,Mon-Tue" , outputString = "* * * 3,1,8 5,1-2" , cronStringFormat = CronStringFormat.Default },
new { inputString = "1 * 1-2,3 * * *" , outputString = "1 * 1-2,3 * * *" , cronStringFormat = CronStringFormat.WithSeconds },
new { inputString = "22 * * * */2 *" , outputString = "22 * * * */2 *" , cronStringFormat = CronStringFormat.WithSeconds },
new { inputString = "33 10-40/15 * * * *" , outputString = "33 10-40/15 * * * *" , cronStringFormat = CronStringFormat.WithSeconds },
new { inputString = "55 * * * Mar,Jan,Aug Fri,Mon-Tue", outputString = "55 * * * 3,1,8 5,1-2" , cronStringFormat = CronStringFormat.WithSeconds },
};

foreach (var test in tests)
Expand Down Expand Up @@ -454,7 +454,7 @@ public void EvaluationsBlank()
//Fire every November 11 at 11:11 AM
new { startTime = "01/07/1984 00:00:00", inputString = "0 11 11 11 11 ?", nextOccurence = "11/11/1984 11:11:00", cronStringFormat = CronStringFormat.WithSeconds },
};

foreach (var test in tests)
CronCall(test.startTime, test.inputString, test.nextOccurence, test.cronStringFormat);
}
Expand All @@ -463,7 +463,7 @@ public void EvaluationsBlank()
[TestMethod]
public void FiniteOccurrences()
{
var tests = new []
var tests = new[]
{
new { inputString = " * * * * * ", startTime = "01/01/2003 00:00:00", endTime = "01/01/2003 00:00:00", cronStringFormat = CronStringFormat.Default },
new { inputString = " * * * * * ", startTime = "31/12/2002 23:59:59", endTime = "01/01/2003 00:00:00", cronStringFormat = CronStringFormat.Default },
Expand Down Expand Up @@ -502,7 +502,6 @@ public void IllegalDates()
BadField("* * 30-31 Feb *", CronStringFormat.Default);
}

[TestMethod]
static void BadField(string expression, CronStringFormat format)
{
Assert2.Throws<CrontabException>(() => CrontabSchedule.Parse(expression, format));
Expand Down
98 changes: 10 additions & 88 deletions NCrontab.Advanced.Tests/NCrontab.Advanced.Tests.csproj
@@ -1,93 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CCAD3304-0882-4244-8F66-1890126AC5C6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NCrontab.Advanced.Tests</RootNamespace>
<AssemblyName>NCrontab.Advanced.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.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>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
</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="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="ConstantTests.cs" />
<Compile Include="CronInstanceTests.cs" />
<Compile Include="Extensions\AssertExtensions.cs" />
<Compile Include="FilterTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NCrontab.Advanced\NCrontab.Advanced.csproj">
<Project>{D56BC51A-E8F9-4911-8C4C-EAB2763699CD}</Project>
<Name>NCrontab.Advanced</Name>
</ProjectReference>
<ProjectReference Include="..\NCrontab.Advanced\NCrontab.Advanced.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>

0 comments on commit 0926b8f

Please sign in to comment.