Skip to content

Commit

Permalink
Add test project.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3wjack committed Jul 5, 2022
1 parent e093ec5 commit 596551a
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ImapCleanup.Tests/ImapCleanup.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ImapCleanup\ImapCleanup.csproj" />
</ItemGroup>

</Project>
70 changes: 70 additions & 0 deletions ImapCleanup.Tests/TimeSpanExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using ImapCleanup.Extensions;

namespace ImapCleanup.Tests
{
public class TimeSpanExtensionsTests
{
[Fact]
public void When_in_timeframe_true_is_returned()
{
var sut = TimeSpan.Parse("13:37");
Assert.True(sut.IsInTimeFrame(new TimeSpan(12, 00, 00), new TimeSpan(14,00,00)));
}

[Fact]
public void When_before_timeframe_false_is_returned()
{
var sut = TimeSpan.Parse("11:37");
Assert.False(sut.IsInTimeFrame(new TimeSpan(12, 00, 00), new TimeSpan(14, 00, 00)));
}

[Fact]
public void When_after_timeframe_false_is_returned()
{
var sut = TimeSpan.Parse("11:37");
Assert.False(sut.IsInTimeFrame(new TimeSpan(12, 00, 00), new TimeSpan(14, 00, 00)));
}

[Fact]
public void When_on_fromTime_true_is_returned()
{
var sut = TimeSpan.Parse("12:00");
Assert.True(sut.IsInTimeFrame(new TimeSpan(12, 00, 00), new TimeSpan(14, 00, 00)));
}

[Fact]
public void When_on_toTime_true_is_returned()
{
var sut = TimeSpan.Parse("14:00");
Assert.True(sut.IsInTimeFrame(new TimeSpan(12, 00, 00), new TimeSpan(14, 00, 00)));
}

[Fact]
public void When_timeframe_spans_days_and_in_timeframe_true_is_returned()
{
var sut = TimeSpan.Parse("23:00");
Assert.True(sut.IsInTimeFrame(new TimeSpan(22, 00, 00), new TimeSpan(6, 00, 00)));
}

[Fact]
public void When_timeframe_spans_days_and_in_timeframe_next_day_true_is_returned()
{
var sut = TimeSpan.Parse("5:00");
Assert.True(sut.IsInTimeFrame(new TimeSpan(22, 00, 00), new TimeSpan(6, 00, 00)));
}

[Fact]
public void When_timeframe_spans_days_and_before_timeframe_false_is_returned()
{
var sut = TimeSpan.Parse("21:00");
Assert.False(sut.IsInTimeFrame(new TimeSpan(22, 00, 00), new TimeSpan(6, 00, 00)));
}

[Fact]
public void When_timeframe_spans_days_and_after_timeframe_false_is_returned()
{
var sut = TimeSpan.Parse("6:01");
Assert.False(sut.IsInTimeFrame(new TimeSpan(22, 00, 00), new TimeSpan(6, 00, 00)));
}
}
}
1 change: 1 addition & 0 deletions ImapCleanup.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
6 changes: 6 additions & 0 deletions ImapCleanup.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImapCleanup", "ImapCleanup\ImapCleanup.csproj", "{F669DDD0-2F89-401D-8529-FB627375CF1D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImapCleanup.Tests", "ImapCleanup.Tests\ImapCleanup.Tests.csproj", "{E4FC16CD-C222-4E96-8A8E-8E75F6DD4944}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{F669DDD0-2F89-401D-8529-FB627375CF1D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F669DDD0-2F89-401D-8529-FB627375CF1D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F669DDD0-2F89-401D-8529-FB627375CF1D}.Release|Any CPU.Build.0 = Release|Any CPU
{E4FC16CD-C222-4E96-8A8E-8E75F6DD4944}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4FC16CD-C222-4E96-8A8E-8E75F6DD4944}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4FC16CD-C222-4E96-8A8E-8E75F6DD4944}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4FC16CD-C222-4E96-8A8E-8E75F6DD4944}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 596551a

Please sign in to comment.