Skip to content

Commit

Permalink
Fixed a unit test. Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
RealDotNetDave committed Aug 6, 2022
1 parent 8869c42 commit 6883de3
Show file tree
Hide file tree
Showing 27 changed files with 13,457 additions and 280 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,4 @@ MigrationBackup/
/source/.cr/team/Options/StorageStreams.xml
/source/6/Benchmarking/dotNetTips.Spargine.6.Benchmarking/.cr/personal/FavoritesList/List.xml
/source/6
/docs/NDepend/NDependOut3
13,124 changes: 13,124 additions & 0 deletions docs/NDepend/dotNetTips.Spargine.6.ndproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 12-17-2020
//
// Last Modified By : David McCarter
// Last Modified On : 07-31-2022
// Last Modified On : 08-06-2022
// ***********************************************************************
// <copyright file="StringExtensionsTests.cs" company="dotNetTips.Spargine.Extensions.Tests">
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
Expand Down Expand Up @@ -56,9 +56,9 @@ public void SplitLinesTest()
var text = Resources.TestMutipleLinesOfText;
try
{
foreach (ReadOnlySpan<char> line in text.SplitLines())
foreach (LineSplitEntry lse in text.SplitLines())
{
Console.WriteLine(line.ToString());
Console.WriteLine(lse.Line.ToString());
}
}
catch
Expand Down Expand Up @@ -138,8 +138,8 @@ public void IsCurrencyCode()
[TestMethod]
public void IsOneToSevenAlphaTest()
{
var goodCode = RandomData.GenerateWord(7);
var badCode = RandomData.GenerateWord(10);
var goodCode = RandomData.GenerateWord(7, 'A', 'Z');
var badCode = RandomData.GenerateWord(25, 'A', 'Z');

Assert.IsTrue(goodCode.IsOneToSevenAlpha());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void DeleteFiles(IEnumerable<string> files)
}
catch (Exception ex) when (ex is ArgumentException ||
ex is ArgumentNullException ||
ex is System.IO.DirectoryNotFoundException ||
ex is DirectoryNotFoundException ||
ex is IOException ||
ex is NotSupportedException ||
ex is PathTooLongException ||
Expand Down
6 changes: 4 additions & 2 deletions source/6/dotNetTips.Spargine.6.Core/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 11-11-2020
//
// Last Modified By : David McCarter
// Last Modified On : 05-23-2022
// Last Modified On : 07-13-2022
// ***********************************************************************
// <copyright file="App.cs" company="McCarter Consulting">
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
Expand All @@ -28,6 +28,7 @@ namespace DotNetTips.Spargine.Core
/// </summary>
public static class App
{

/// <summary>
/// The temporary ASP files location.
/// </summary>
Expand Down Expand Up @@ -157,7 +158,7 @@ public static bool IsRunningFromAspNet()
/// Determines whether user is administrator.
/// </summary>
/// <returns><c>true</c> if [is user administrator]; otherwise, <c>false</c>.</returns>
/// <exception cref="PlatformNotSupportedException"></exception>
/// <exception cref="System.PlatformNotSupportedException"></exception>
[Information(UnitTestCoverage = 100, Status = Status.Available, Documentation = "https://bit.ly/SpargineJun2021")]
public static bool IsUserAdministrator()
{
Expand Down Expand Up @@ -329,5 +330,6 @@ public static void RunAsAdministrator()
/// <value>The working set.</value>
[Information(UnitTestCoverage = 100, Status = Status.Available, Documentation = "https://bit.ly/SpargineJun2021")]
public static long WorkingSet => Environment.WorkingSet;

}
}
6 changes: 4 additions & 2 deletions source/6/dotNetTips.Spargine.6.Core/Logging/LoggingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 09-28-2020
//
// Last Modified By : David McCarter
// Last Modified On : 07-14-2022
// Last Modified On : 08-06-2022
// ***********************************************************************
// <copyright file="LoggingHelper.cs" company="dotNetTips.Spargine.Core">
// Copyright (c) McCarter Consulting. All rights reserved.
Expand All @@ -24,6 +24,7 @@ namespace DotNetTips.Spargine.Core.Logging
/// </summary>
public static class LoggingHelper
{

/// <summary>
/// The application domain exception logger
/// </summary>
Expand Down Expand Up @@ -79,7 +80,7 @@ private static void CurrentDomain_FirstChanceException(object sender, FirstChanc
///// <exception cref="ArgumentNullException">logger</exception>
///// <exception cref="ArgumentException">'{nameof(message)}' cannot be null or empty. - message</exception>
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//[Information(nameof(FastLogger), author: "David McCarter", createdOn: "3/21/2022", UnitTestCoverage = 0, BenchMarkStatus = BenchMarkStatus.None, Status = Status.New, Documentation = "ADD URL")]
//[Information(nameof(FastLogger), author: "David McCarter", createdOn: "3/21/2022", UnitTestCoverage = 0, BenchMarkStatus = BenchMarkStatus.None, Status = Status.Available, Documentation = "ADD URL")]
//public static void FastLogger([NotNull] ILogger logger, LogLevel logLevel, string message, [AllowNull] Exception ex)
//{
// logger = logger.ArgumentNotNull();
Expand Down Expand Up @@ -267,5 +268,6 @@ public static Exception[] RetrieveAllExceptions([NotNull] Exception exception)

return collection.ToArray();
}

}
}
25 changes: 18 additions & 7 deletions source/6/dotNetTips.Spargine.6.Core/MessageNotQueuedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 09-28-2020
//
// Last Modified By : David McCarter
// Last Modified On : 01-21-2022
// Last Modified On : 07-17-2022
// ***********************************************************************
// <copyright file="MessageNotQueuedException.cs" company="dotNetTips.Spargine.Core">
// Copyright (c) McCarter Consulting. All rights reserved.
Expand All @@ -26,6 +26,17 @@ namespace DotNetTips.Spargine.Core
[Serializable]
public class MessageNotQueuedException : LoggableException
{

/// <summary>
/// Initializes a new instance of the <see cref="MessageNotQueuedException" /> class.
/// </summary>
/// <param name="serializationInfo">The serialization information.</param>
/// <param name="streamingContext">The streaming context.</param>
/// <exception cref="NotImplementedException">The exception.</exception>
/// <exception cref="NotImplementedException">The exception.</exception>
protected MessageNotQueuedException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MessageNotQueuedException" /> class.
/// </summary>
Expand Down Expand Up @@ -66,13 +77,12 @@ public MessageNotQueuedException(string message, Exception innerException) : bas
public MessageNotQueuedException(string message, string messageId, Exception innerException) : base(message, innerException) => this.MessageId = messageId;

/// <summary>
/// Initializes a new instance of the <see cref="MessageNotQueuedException" /> class.
/// Initializes a new instance of the <see cref="MessageNotQueuedException"/> class.
/// </summary>
/// <param name="serializationInfo">The serialization information.</param>
/// <param name="streamingContext">The streaming context.</param>
/// <exception cref="NotImplementedException">The exception.</exception>
/// <exception cref="NotImplementedException">The exception.</exception>
protected MessageNotQueuedException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
/// <param name="message">The message.</param>
/// <param name="ex">The ex.</param>
/// <param name="userMessage">The user message.</param>
public MessageNotQueuedException(string message, Exception ex, string userMessage) : base(message, ex, userMessage)
{
}

Expand All @@ -81,5 +91,6 @@ protected MessageNotQueuedException(SerializationInfo serializationInfo, Streami
/// </summary>
/// <value>The message identifier.</value>
public string MessageId { get; }

}
}
8 changes: 5 additions & 3 deletions source/6/dotNetTips.Spargine.6.Core/Validator.Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 02-16-2022
//
// Last Modified By : David McCarter
// Last Modified On : 06-02-2022
// Last Modified On : 08-06-2022
// ***********************************************************************
// <copyright file="Validator.Argument.cs" company="David McCarter - dotNetTips.com">
// McCarter Consulting (David McCarter)
Expand All @@ -26,6 +26,7 @@ namespace DotNetTips.Spargine.Core
/// </summary>
public static partial class Validator
{

/// <summary>
/// Creates the exception message.
/// </summary>
Expand Down Expand Up @@ -470,7 +471,7 @@ public static IEnumerable<T> ArgumentItemsExists<T>(this IEnumerable<T> input, s
///// <param name="errorMessage">The error message.</param>
///// <param name="paramName">Name of the parameter.</param>
///// <returns>IReadOnlyList&lt;T&gt;.</returns>
//[Information(nameof(ArgumentItemsExists), "David McCarter", "5/25/2022", UnitTestCoverage = 0, BenchMarkStatus = BenchMarkStatus.NotRequired, Status = Status.New)]
//[Information(nameof(ArgumentItemsExists), "David McCarter", "5/25/2022", UnitTestCoverage = 0, BenchMarkStatus = BenchMarkStatus.NotRequired, Status = Status.Available)]
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public static IReadOnlyList<T> ArgumentItemsExists<T>(this IReadOnlyList<T> input, string errorMessage = "", [CallerArgumentExpression("input")] string paramName = "")
//{
Expand All @@ -492,7 +493,7 @@ public static IEnumerable<T> ArgumentItemsExists<T>(this IEnumerable<T> input, s
///// <param name="errorMessage">The error message.</param>
///// <param name="paramName">Name of the parameter.</param>
///// <returns>IReadOnlyCollection&lt;T&gt;.</returns>
//[Information(nameof(ArgumentItemsExists), "David McCarter", "5/27/2022", UnitTestCoverage = 0, BenchMarkStatus = BenchMarkStatus.NotRequired, Status = Status.New)]
//[Information(nameof(ArgumentItemsExists), "David McCarter", "5/27/2022", UnitTestCoverage = 0, BenchMarkStatus = BenchMarkStatus.NotRequired, Status = Status.Available)]
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public static IReadOnlyCollection<T> ArgumentItemsExists<T>(this IReadOnlyCollection<T> input, string errorMessage = "", [CallerArgumentExpression("input")] string paramName = "")
//{
Expand Down Expand Up @@ -838,5 +839,6 @@ public static ICollection<T> ArgumentNotReadOnly<T>(this ICollection<T> input, s

return input!;
}

}
}
10 changes: 5 additions & 5 deletions source/6/dotNetTips.Spargine.6.Extensions/ArrayExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 11-21-2020
//
// Last Modified By : David McCarter
// Last Modified On : 07-17-2022
// Last Modified On : 08-06-2022
// ***********************************************************************
// <copyright file="ArrayExtensions.cs" company="dotNetTips.Spargine.6.Extensions">
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
Expand Down Expand Up @@ -278,7 +278,7 @@ public static bool ContainsAny<T>([NotNull] this T[] array, [NotNull] params T[]
/// <typeparam name="T"></typeparam>
/// <param name="list">The list.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
[Information(nameof(DoesNotHaveItems), author: "David McCarter", createdOn: "6/17/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.New, Documentation = "ADD URL")]
[Information(nameof(DoesNotHaveItems), author: "David McCarter", createdOn: "6/17/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.Available, Documentation = "ADD URL")]
public static bool DoesNotHaveItems<T>([AllowNull] this T[] list)
{
if (list is null)
Expand Down Expand Up @@ -335,7 +335,7 @@ public static int GenerateHashCode<T>([NotNull] this T[] array)
/// <param name="array">The array.</param>
/// <returns><c>true</c> if the specified array has items; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.New, Documentation = "ADD URL")]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.Available, Documentation = "ADD URL")]
public static bool HasItems<T>([AllowNull] this T[] array)
{
if (array is null)
Expand All @@ -356,7 +356,7 @@ public static bool HasItems<T>([AllowNull] this T[] array)
/// <param name="action">The action.</param>
/// <returns><c>true</c> if the specified action has items; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.New, Documentation = "ADD URL")]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.Available, Documentation = "ADD URL")]
public static bool HasItems<T>([AllowNull] this T[] array, [NotNull] Func<T, bool> action)
{
if (array is null || action is null)
Expand All @@ -377,7 +377,7 @@ public static bool HasItems<T>([AllowNull] this T[] array, [NotNull] Func<T, boo
/// <param name="count">The count.</param>
/// <returns><c>true</c> if the specified count has items; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.New, Documentation = "ADD URL")]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.Completed, Status = Status.Available, Documentation = "ADD URL")]
public static bool HasItems<T>([AllowNull] this T[] array, int count)
{
if (array is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 11-21-2020
//
// Last Modified By : David McCarter
// Last Modified On : 07-17-2022
// Last Modified On : 07-26-2022
// ***********************************************************************
// <copyright file="CollectionExtensions.cs" company="David McCarter - dotNetTips.com">
// McCarter Consulting (David McCarter)
Expand All @@ -25,6 +25,7 @@ namespace DotNetTips.Spargine.Extensions
/// </summary>
public static class CollectionExtensions
{

/// <summary>
/// Adds item to the <see cref="ICollection{T}" /> if the condition is meet.
/// Validates that <paramref name="collection" /> and <paramref name="item" /> is not null.
Expand Down Expand Up @@ -122,9 +123,9 @@ public static bool AddIfNotExists<T>([NotNull] this ICollection<T> collection, [
/// <exception cref="ArgumentReadOnlyException">List cannot be read-only.</exception>
/// <exception cref="ArgumentNullException">Collection cannot be <see langword="null" />.</exception>
/// <example>
/// <code>
/// people.AddIfNotExists(person, comparer)
/// </code>
/// <code>
/// people.AddIfNotExists(person, comparer)
/// </code>
/// </example>
[Information("From .NET Core source.", author: "David McCarter", createdOn: "7/15/2020", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.None, Status = Status.Available)]
public static bool AddIfNotExists<T>([NotNull] this ICollection<T> collection, [NotNull] T item, [NotNull] IEqualityComparer<T> comparer)
Expand Down Expand Up @@ -159,7 +160,7 @@ public static bool AddIfNotExists<T>([NotNull] this ICollection<T> collection, [
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <exception cref="ArgumentReadOnlyException">Collection cannot be read-only.</exception>
/// <example>
/// <code>
/// <code>
/// people.AddRange(personCollection, Tristate.UseDefault)
/// </code>
/// </example>
Expand Down Expand Up @@ -305,5 +306,6 @@ public static void Upsert([NotNull] this ICollection<IDataRecord> collection, [N

collection.Add(item);
}

}
}
34 changes: 18 additions & 16 deletions source/6/dotNetTips.Spargine.6.Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 11-21-2020
//
// Last Modified By : David McCarter
// Last Modified On : 07-31-2022
// Last Modified On : 08-06-2022
// ***********************************************************************
// <copyright file="DictionaryExtensions.cs" company="dotNetTips.Spargine.6.Extensions">
// Copyright (c) David McCarter - dotNetTips.com. All rights reserved.
Expand All @@ -29,6 +29,7 @@ namespace DotNetTips.Spargine.Extensions
/// </summary>
public static class DictionaryExtensions
{

/// <summary>
/// Processes the collection to dispose.
/// </summary>
Expand Down Expand Up @@ -171,12 +172,25 @@ public static TValue GetOrAdd<TKey, TValue>([NotNull] this IDictionary<TKey, TVa
/// <param name="action">The action.</param>
/// <returns><c>true</c> if the specified action has items; otherwise, <c>false</c>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.None, Status = Status.New, Documentation = "ADD URL")]
[Information(nameof(HasItems), author: "David McCarter", createdOn: "6/15/2022", UnitTestCoverage = 100, BenchMarkStatus = BenchMarkStatus.None, Status = Status.Available, Documentation = "ADD URL")]
public static bool HasItems<TKey, TValue>([AllowNull] this IDictionary<TKey, TValue> collection, [NotNull] Func<KeyValuePair<TKey, TValue>, bool> action)
{
return collection is not null && action is not null && collection.Any(action);
}

/// <summary>
/// Converts to a <see cref="Dictionary{TKey, TValue}" /> to a <see cref="ConcurrentDictionary{TKey, TValue}" />.
/// </summary>
/// <typeparam name="TKey">The type of the t key.</typeparam>
/// <typeparam name="TValue">The type of the t value.</typeparam>
/// <param name="collection">The collection.</param>
/// <returns>ConcurrentDictionary&lt;TKey, TValue&gt;.</returns>
[Information(nameof(ToSortedDictionary), "David McCarter", "7/23/2022", BenchMarkStatus = BenchMarkStatus.None, UnitTestCoverage = 100, Status = Status.Available, Documentation = "ADD URL")]
public static ConcurrentDictionary<TKey, TValue> ToConcurrentDictionary<TKey, TValue>([NotNull] this Dictionary<TKey, TValue> collection)
{
return new ConcurrentDictionary<TKey, TValue>(collection.ArgumentNotNull());
}

/// <summary>
/// Converts <see cref="IDictionary" /> to delimited string.
/// </summary>
Expand Down Expand Up @@ -231,25 +245,12 @@ public static ImmutableDictionary<TKey, TValue> ToImmutable<TKey, TValue>([NotNu
/// <typeparam name="TValue">The type of the t value.</typeparam>
/// <param name="collection">The dictionary.</param>
/// <returns>SortedDictionary&lt;TKey, TValue&gt;.</returns>
[Information(nameof(ToSortedDictionary), "David McCarter", "6/27/2022", BenchMarkStatus = BenchMarkStatus.Completed, UnitTestCoverage = 100, Status = Status.New, Documentation = "ADD URL")]
[Information(nameof(ToSortedDictionary), "David McCarter", "6/27/2022", BenchMarkStatus = BenchMarkStatus.Completed, UnitTestCoverage = 100, Status = Status.Available, Documentation = "ADD URL")]
public static SortedDictionary<TKey, TValue> ToSortedDictionary<TKey, TValue>([NotNull] this Dictionary<TKey, TValue> collection)
{
return new SortedDictionary<TKey, TValue>(collection.ArgumentNotNull());
}

/// <summary>
/// Converts to a <see cref="Dictionary{TKey, TValue}" /> to a <see cref="ConcurrentDictionary{TKey, TValue}" />.
/// </summary>
/// <typeparam name="TKey">The type of the t key.</typeparam>
/// <typeparam name="TValue">The type of the t value.</typeparam>
/// <param name="collection">The collection.</param>
/// <returns>ConcurrentDictionary&lt;TKey, TValue&gt;.</returns>
[Information(nameof(ToSortedDictionary), "David McCarter", "7/23/2022", BenchMarkStatus = BenchMarkStatus.None, UnitTestCoverage = 1000, Status = Status.New, Documentation = "ADD URL")]
public static ConcurrentDictionary<TKey, TValue> ToConcurrentDictionary<TKey, TValue>([NotNull] this Dictionary<TKey, TValue> collection)
{
return new ConcurrentDictionary<TKey, TValue>(collection.ArgumentNotNull());
}

/// <summary>
/// Upserts the specified item into the <see cref="IDictionary{TKey, TValue}" />.
/// Validates that <paramref name="collection" /> and <paramref name="item" /> is not null.
Expand Down Expand Up @@ -302,5 +303,6 @@ public static void Upsert<TKey, TValue>([NotNull] this IDictionary<TKey, TValue>

collection.Add(key, item);
}

}
}
Loading

0 comments on commit 6883de3

Please sign in to comment.