Skip to content
Open
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
16 changes: 16 additions & 0 deletions csharp/Platform.Ranges.Tests/RangeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,21 @@ public static void EqualityTest()
Assert.True(range1 != range2);
Assert.NotEqual(range1, range2);
}

[Fact]
public static void PositiveRangesTest()
{
Assert.Equal(1, Range.PositiveSByte.Minimum);
Assert.Equal(sbyte.MaxValue, Range.PositiveSByte.Maximum);

Assert.Equal(1, Range.PositiveInt16.Minimum);
Assert.Equal(short.MaxValue, Range.PositiveInt16.Maximum);

Assert.Equal(1, Range.PositiveInt32.Minimum);
Assert.Equal(int.MaxValue, Range.PositiveInt32.Maximum);

Assert.Equal(1L, Range.PositiveInt64.Minimum);
Assert.Equal(long.MaxValue, Range.PositiveInt64.Maximum);
}
}
}
24 changes: 24 additions & 0 deletions csharp/Platform.Ranges/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,29 @@ public static class Range
/// <para>Возвращает весь диапазон значений <see cref="decimal"/>.</para>
/// </summary>
public static readonly Range<decimal> Decimal = new Range<decimal>(decimal.MinValue, decimal.MaxValue);

/// <summary>
/// <para>Gets the positive <see cref="sbyte"/> values range (from 1 to <see cref="sbyte.MaxValue"/>).</para>
/// <para>Возвращает положительный диапазон значений <see cref="sbyte"/> (от 1 до <see cref="sbyte.MaxValue"/>).</para>
/// </summary>
public static readonly Range<sbyte> PositiveSByte = new Range<sbyte>(1, sbyte.MaxValue);

/// <summary>
/// <para>Gets the positive <see cref="short"/> values range (from 1 to <see cref="short.MaxValue"/>).</para>
/// <para>Возвращает положительный диапазон значений <see cref="short"/> (от 1 до <see cref="short.MaxValue"/>).</para>
/// </summary>
public static readonly Range<short> PositiveInt16 = new Range<short>(1, short.MaxValue);

/// <summary>
/// <para>Gets the positive <see cref="int"/> values range (from 1 to <see cref="int.MaxValue"/>).</para>
/// <para>Возвращает положительный диапазон значений <see cref="int"/> (от 1 до <see cref="int.MaxValue"/>).</para>
/// </summary>
public static readonly Range<int> PositiveInt32 = new Range<int>(1, int.MaxValue);

/// <summary>
/// <para>Gets the positive <see cref="long"/> values range (from 1 to <see cref="long.MaxValue"/>).</para>
/// <para>Возвращает положительный диапазон значений <see cref="long"/> (от 1 до <see cref="long.MaxValue"/>).</para>
/// </summary>
public static readonly Range<long> PositiveInt64 = new Range<long>(1L, long.MaxValue);
}
}
Loading