-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from calebjenkins/develop
Release 1.5.0
- Loading branch information
Showing
8 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
| ||
namespace ExtensionTests; | ||
|
||
using Calebs.Extensions; | ||
|
||
public class ObjectExtensionTests | ||
{ | ||
[Fact] | ||
public void Nullable_Objects_Should_Return_Empty_String() | ||
{ | ||
ExampleModel m = null; | ||
var result = m.ToSafeString(); | ||
result.IsNullOrEmpty().Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void Int_Should_Return_String_Value() | ||
{ | ||
int five = 5; | ||
var result = five.ToSafeString(); | ||
result.Should().Be("5"); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,5 +26,4 @@ public void ShouldReturnValueIfNotNull() | |
|
||
v2.Should().Be(value); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
| ||
namespace Calebs.Extensions.Console | ||
{ | ||
public static class ConsoleExtensions | ||
{ | ||
public static void WriteLine (this System.ConsoleColor color, string text) | ||
{ | ||
color.Write(text); | ||
System.Console.WriteLine(); | ||
} | ||
|
||
public static void Write (this System.ConsoleColor color, string text) | ||
{ | ||
var currentColor = System.Console.ForegroundColor; | ||
System.Console.ForegroundColor = color; | ||
System.Console.Write(text); | ||
System.Console.ForegroundColor = currentColor; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Calebs.Extensions; | ||
|
||
public static class ObjectExtensions | ||
{ | ||
public static string ToSafeString(this object o) | ||
{ | ||
return o?.ToString() ?? string.Empty; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ public static string ValueOrEmpty(this string? value) | |
return value; | ||
} | ||
} | ||
|