Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Apr 29, 2024
2 parents f82c482 + 4d29042 commit 8e9db52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 4 additions & 7 deletions CSUtilities.Tests/Extensions/StringExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CSUtilities.Extensions;
using Xunit;

namespace CSUtilities.Tests.Extensions
{
public class StringExtensionsTests
{
[Fact]
public void GetStringValueTest()
public void IsNullOrEmptyTest()
{

string n = null;
Assert.True(n.IsNullOrEmpty());
}
}
}
10 changes: 9 additions & 1 deletion CSUtilities/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;

namespace CSUtilities.Extensions
{
//TODO: refactor extensions
/// <summary>
/// String utility extensions.
/// </summary>
Expand All @@ -25,6 +25,14 @@ public static bool IsNullOrWhiteSpace(this string str)
return string.IsNullOrWhiteSpace(str);
}

public static void TrowIfNullOrEmpty(this string str, [CallerMemberName] string name = null)
{
if (string.IsNullOrEmpty(str))
{
throw new ArgumentException("", name);
}
}

/// <summary>
/// Return an array with all the lines.
/// </summary>
Expand Down

0 comments on commit 8e9db52

Please sign in to comment.