Awesome
SheepTools
SheepTools | ||
---|---|---|
SheepTools.Moq | ||
SheepTools.XUnit |
SheepTools is a .NET toolbox library (yet another!) which contains handy classes, extension methods, etc.
It's divided in different libraries so that using the general purpose, main one doesn't imply adding any transitive dependencies to your project.
I'm more than happy to accept suggestions, comments, or addition proposals.
Relevant info
- .NET Standard 2.0 and 2.1 were supported until v0.2.x.
Nullable
is enabled from v0.2.x.
Content
-
- Point
- IntPoint
- IntPointWithValue
- Point3D
- Line
- BitMatrix
- BitArrayComparer
- TreeNode
- Node
- Ensure
- RangeHelpers
- LinearInterpolation
- AssemblyExtensions
- BitArrayExtensions
- CharExtensions
- CollectionExtensions
- DateTimeExtensions
- DictionaryExtensions
- DirectionExtensions
- DoubleExtensions
- EnumerableExtensions
- IntExtensions
- NumericExtensions
- StringExtensions
- StopwatchExtensions
- Vector2Extensions
<a name="sheeptools"></a>
SheepTools
<a name="point"></a>
Point
2D Point class with an optional string
Id.
<a name="intpoint"></a>
IntPoint
Slim 2D Point class, using ints and without an optional string
Value
<a name="point3d"></a>
IntPointWithValue
Slim 2D Point class, using ints and with and optional string
Id
<a name="point3d"></a>
Point3D
3D point class with an optional string
Id.
<a name="line"></a>
Line
2D (straight) line class.
<a name="bitmatrix"></a>
BitMatrix
Class to work with bidimensional matrixes of bits.
<a name="bitarray-comparer"></a>
BitArrayComparer
IEqualityComparer<BitArray>
implementation
<a name="tree-node"></a>
TreeNode
Tree node class with a generic key.
<a name="node"></a>
Node
Tree node class with a string
key.
Essentially, TreeNode<string>
.
<a name="maths"></a>
Maths
General math algorithms
LeastCommonMultiple(this IEnumerable<ulong>)
LeastCommonMultiple(ulong, ulong)
GreatestCommonDivisor(this IEnumerable<ulong>)
GreatestCommonDivisor(ulong, ulong)
<a name="ensure"></a>
Ensure
Assert-style class that throws exceptions when things don't go as expected.
Equal()
/NotEqual()
Equals()
/NotEquals()
True()
/False()
Null()
/NotNull()
Empty()
/NotEmpty()
NullOrEmpty()
/NotNullOrEmpty()
NullOrWhiteSpace()
/NotNullOrWhiteSpace()
Count<T>(int, IEnumerable<T>, Func<T, bool>)
<a name="rangehelpers"></a>
RangeHelpers
Helper class to generate ranges of numbers before having to check if it was (a, b), [a, b] or (a, b] in Microsoft documentation every time I use Enumberable.Range
.
GenerateRange(int, int)
-> [a, b]
<a name="lerp"></a>
LinearInterpolation
Helper methods to interpolate 2D points
InterpolateLinearly(double, double, double, double, double)
InterpolateYLinearly(double, Point, point)
InterpolateXLinearly(double, Point, point)
<a name="assembly-extensions"></a>
AssemblyExtensions
GetTypes<TAttribute>()
GetTypesAndAttributes<TAttribute>()
GetAssemblies<TInterface>()
<a name="bitarray-extensions"></a>
BitArrayExtensions
Reverse()
ToBitString()
<a name="char-extensions"></a>
CharExtensions
GetDirection()
<a name="string-extensions"></a>
<a name="collection-extensions"></a>
CollectionExtensions
AddRange()
RemoveAll()
<a name="datetime-extensions"></a>
DateTimeExtensions
IsAfterNow()
IsAfter(DateTime)
MillisecondsFromEpoch()
StringId()
<a name="dictionary-extensions"></a>
DictionaryExtensions
AddOrUpdate(TKey, TValue, Func<TKey, TValue, TValue>)
AddOrUpdate(TKey, Func<TKey, TValue>, Func<TKey, TValue, TValue>)
AddOrUpdate(TKey, Func<TKey, TArg, TValue>, Func<TKey, TValue, TArg, TValue>, TArg)
<a name="direction-extensions"></a>
DirectionExtensions
TurnLeft()
TurnRight()
Turn180()
Opposite()
<a name="double-extensions"></a>
DoubleExtensions
DoubleEquals(double, precision)
<a name="enumerable-extensions"></a>
EnumerableExtensions
ForEach()
IsNullOrEmpty()
IntersectAll()
<a name="int-extensions"></a>
IntExtensions
Factorial()
Clamp(int, int)
<a name="numeric-extensions"></a>
NumericExtensions
Clamp<T>(T, T)
<a name="stopwatch-extensions"></a>
StopwatchExtensions
ElapsedMilliseconds()
ToFriendlyString()
<a name="string-extensions"></a>
StringExtensions
IsEmpty()
IsWhiteSpace()
HasWhiteSpaces()
Truncate(int)
ReverseString()
ToBitArray(char = '1')
ToBoolEnumerable(char = '1')
RemoveBlanksAndMakeInvariant()
IsPalindrome()
<a name="vector2-extensions"></a>
Vector2Extensions
Move(Direction, int)
Move(char, int)
DistanceTo()
ManhattanDistance()
ChebyshevDistance()
RotateCounterclockwise()
RotateClockwise()
ToFriendlyString()
<a name="sheeptools-moq"></a>
SheepTools.Moq
Depends on Moq and Microsoft.Extensions.Logging.
<a name="moq-logger-extensions"></a>
MoqLoggerExtensions
Helps verifying ILogger
invocations.
-
VerifyLog(LogLevel, Message, Times)
-
VerifyLog<TException>(LogLevel, Exception, Message, Times)
<a name="moq-genericlogger-extensions"></a>
MoqGenericLoggerExtensions
Helps verifying ILogger<T>
invocations.
-
VerifyLog<T>(LogLevel, Message, Times)
-
VerifyLog<T, TException>(LogLevel, Exception, Message, Times)
<a name="sheeptools-xunit"></a>
SheepTools.XUnit
<a name="asssert"></a>
Depends on XUnit.
Asssert
DoesNotThrow(Action)
DoesNotThrow(Func<object)
DoesNotThrowAsync(Func<Task>)