Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions Source/Testably.Expectations/Extensions/ChronologyExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using System;

namespace Testably.Expectations.Extensions;

/// <summary>
/// Extension methods for chronology methods.
/// </summary>
public static class ChronologyExtensions
{
/// <summary>
/// Converts the <paramref name="days" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Days(this int days)
=> TimeSpan.FromDays(days);

/// <summary>
/// Converts the <paramref name="days" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Days(this double days)
=> TimeSpan.FromDays(days);

/// <summary>
/// Converts the <paramref name="days" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Days(this int days, TimeSpan offset)
=> TimeSpan.FromDays(days).Add(offset);

/// <summary>
/// Converts the <paramref name="days" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Days(this double days, TimeSpan offset)
=> TimeSpan.FromDays(days).Add(offset);

/// <summary>
/// Converts the <paramref name="hours" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Hours(this int hours)
=> TimeSpan.FromHours(hours);

/// <summary>
/// Converts the <paramref name="hours" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Hours(this double hours)
=> TimeSpan.FromHours(hours);

/// <summary>
/// Converts the <paramref name="hours" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Hours(this int hours, TimeSpan offset)
=> TimeSpan.FromHours(hours).Add(offset);

/// <summary>
/// Converts the <paramref name="hours" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Hours(this double hours, TimeSpan offset)
=> TimeSpan.FromHours(hours).Add(offset);

/// <summary>
/// Converts the <paramref name="milliseconds" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Milliseconds(this int milliseconds)
=> TimeSpan.FromMilliseconds(milliseconds);

/// <summary>
/// Converts the <paramref name="milliseconds" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Milliseconds(this double milliseconds)
=> TimeSpan.FromMilliseconds(milliseconds);

/// <summary>
/// Converts the <paramref name="milliseconds" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Milliseconds(this int milliseconds, TimeSpan offset)
=> TimeSpan.FromMilliseconds(milliseconds).Add(offset);

/// <summary>
/// Converts the <paramref name="milliseconds" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Milliseconds(this double milliseconds, TimeSpan offset)
=> TimeSpan.FromMilliseconds(milliseconds).Add(offset);

/// <summary>
/// Converts the <paramref name="minutes" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Minutes(this int minutes)
=> TimeSpan.FromMinutes(minutes);

/// <summary>
/// Converts the <paramref name="minutes" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Minutes(this double minutes)
=> TimeSpan.FromMinutes(minutes);

/// <summary>
/// Converts the <paramref name="minutes" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Minutes(this int minutes, TimeSpan offset)
=> TimeSpan.FromMinutes(minutes).Add(offset);

/// <summary>
/// Converts the <paramref name="minutes" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Minutes(this double minutes, TimeSpan offset)
=> TimeSpan.FromMinutes(minutes).Add(offset);

/// <summary>
/// Converts the <paramref name="seconds" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Seconds(this int seconds)
=> TimeSpan.FromSeconds(seconds);

/// <summary>
/// Converts the <paramref name="seconds" /> into a corresponding <see cref="TimeSpan" />.
/// </summary>
public static TimeSpan Seconds(this double seconds)
=> TimeSpan.FromSeconds(seconds);

/// <summary>
/// Converts the <paramref name="seconds" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Seconds(this int seconds, TimeSpan offset)
=> TimeSpan.FromSeconds(seconds).Add(offset);

/// <summary>
/// Converts the <paramref name="seconds" /> into a corresponding <see cref="TimeSpan" /> and add the given
/// <paramref name="offset" />.
/// </summary>
public static TimeSpan Seconds(this double seconds, TimeSpan offset)
=> TimeSpan.FromSeconds(seconds).Add(offset);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using AutoFixture.Xunit2;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;
using System.Collections.Generic;

namespace Testably.Expectations.Tests.Collections;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Collections;
namespace Testably.Expectations.Tests.Collections;

public sealed partial class ThatCollection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Testably.Expectations.Tests.Collections;
public partial class ThatCollection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#if NET6_0_OR_GREATER
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Xunit;

namespace Testably.Expectations.Tests.Core.Ambient;

Expand Down
5 changes: 1 addition & 4 deletions Tests/Testably.Expectations.Tests/Core/BecauseTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Threading.Tasks;
using Testably.Expectations.Tests.TestHelpers;
using Xunit;
using Testably.Expectations.Tests.TestHelpers;

namespace Testably.Expectations.Tests.Core;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using AutoFixture.Xunit2;
using System.Threading.Tasks;
using Testably.Expectations.Core.Constraints;
using Xunit;
using Testably.Expectations.Core.Constraints;

namespace Testably.Expectations.Tests.Core;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using AutoFixture.Xunit2;
using System.Threading.Tasks;
using Xunit;

namespace Testably.Expectations.Tests.Core.Exceptions;
namespace Testably.Expectations.Tests.Core.Exceptions;

public sealed class FailExceptionTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using AutoFixture.Xunit2;
using System.Threading.Tasks;
using Xunit;

namespace Testably.Expectations.Tests.Core.Exceptions;
namespace Testably.Expectations.Tests.Core.Exceptions;

public sealed class SkipExceptionTests
{
Expand Down
5 changes: 1 addition & 4 deletions Tests/Testably.Expectations.Tests/Core/ExpectationTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Threading.Tasks;
using Xunit;

namespace Testably.Expectations.Tests.Core;
namespace Testably.Expectations.Tests.Core;

public sealed class ExpectationTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Testably.Expectations.Core.Formatting;
using Xunit;

namespace Testably.Expectations.Tests.Core.Formatting;
namespace Testably.Expectations.Tests.Core.Formatting;

public sealed class DefaultFormatterTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Testably.Expectations.Core.Formatting;
using Xunit;

namespace Testably.Expectations.Tests.Core.Formatting.Formatters;
namespace Testably.Expectations.Tests.Core.Formatting.Formatters;

public sealed class BooleanFormatterTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Testably.Expectations.Core.Formatting;
using Xunit;

namespace Testably.Expectations.Tests.Core.Formatting.Formatters;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Testably.Expectations.Core.Formatting;
using Xunit;

namespace Testably.Expectations.Tests.Core.Formatting.Formatters;
namespace Testably.Expectations.Tests.Core.Formatting.Formatters;

public sealed class NumberFormatterTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Testably.Expectations.Core.Formatting;
using Xunit;

namespace Testably.Expectations.Tests.Core.Formatting.Formatters;
namespace Testably.Expectations.Tests.Core.Formatting.Formatters;

public sealed class StringFormatterTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Threading.Tasks;
using Testably.Expectations.Core.Formatting;
using Xunit;

namespace Testably.Expectations.Tests.Core.Formatting.Formatters;
namespace Testably.Expectations.Tests.Core.Formatting.Formatters;

public sealed class TypeFormatterTests
{
Expand Down
5 changes: 1 addition & 4 deletions Tests/Testably.Expectations.Tests/Core/Nodes/AndNodeTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Threading.Tasks;
using Xunit;

namespace Testably.Expectations.Tests.Core.Nodes;
namespace Testably.Expectations.Tests.Core.Nodes;

public sealed class AndNodeTests
{
Expand Down
5 changes: 1 addition & 4 deletions Tests/Testably.Expectations.Tests/Core/Nodes/OrNodeTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Threading.Tasks;
using Xunit;

namespace Testably.Expectations.Tests.Core.Nodes;
namespace Testably.Expectations.Tests.Core.Nodes;

public sealed class OrNodeTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Threading.Tasks;
using Xunit;

namespace Testably.Expectations.Tests.Core.Nodes;
namespace Testably.Expectations.Tests.Core.Nodes;

public sealed class PrecedenceTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System.Threading.Tasks;
using Xunit;
using Xunit.Sdk;

namespace Testably.Expectations.Tests.Core.Nodes;
namespace Testably.Expectations.Tests.Core.Nodes;

public sealed class WhichNodeTests
{
Expand Down
Loading
Loading