-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # lib12/lib12.csproj
- Loading branch information
Showing
12 changed files
with
239 additions
and
7 deletions.
There are no files selected for viewing
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
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,21 @@ | ||
using lib12.Mathematics.Extensions; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace lib12.Tests.Mathematics | ||
{ | ||
public class BoolExtensionTests | ||
{ | ||
[Fact] | ||
public void to_int_returns_1_if_source_is_true() | ||
{ | ||
true.ToInt().ShouldBe(1); | ||
} | ||
|
||
[Fact] | ||
public void to_int_returns_0_if_source_is_false() | ||
{ | ||
false.ToInt().ShouldBe(0); | ||
} | ||
} | ||
} |
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,21 @@ | ||
using lib12.Mathematics.Extensions; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace lib12.Tests.Mathematics | ||
{ | ||
public class IntExtensionTests | ||
{ | ||
[Fact] | ||
public void to_bool_returns_false_if_given_zero() | ||
{ | ||
0.ToBool().ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void to_bool_returns_true_if_given_non_zero() | ||
{ | ||
12.ToBool().ShouldBeTrue(); | ||
} | ||
} | ||
} |
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 @@ | ||
using lib12.Reflection; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace lib12.Tests.Reflection | ||
{ | ||
public class TypeExtensionTests | ||
{ | ||
private static class StaticClass { } | ||
private class NonStaticClass { } | ||
|
||
[Fact] | ||
public void is_static_returns_true_for_static_class() | ||
{ | ||
typeof(StaticClass).IsStatic().ShouldBeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void is_static_returns_false_for_non_static_class() | ||
{ | ||
typeof(NonStaticClass).IsStatic().ShouldBeFalse(); | ||
} | ||
} | ||
} |
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
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,15 @@ | ||
namespace lib12.Mathematics.Extensions | ||
{ | ||
public static class BoolExtension | ||
{ | ||
/// <summary> | ||
/// Converts bool to int | ||
/// </summary> | ||
/// <param name="source">The source bool</param> | ||
/// <returns>1 if true, 0 if false</returns> | ||
public static int ToInt(this bool source) | ||
{ | ||
return source ? 1 : 0; | ||
} | ||
} | ||
} |
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,15 @@ | ||
namespace lib12.Mathematics.Extensions | ||
{ | ||
public static class IntExtension | ||
{ | ||
/// <summary> | ||
/// Converts int to bool | ||
/// </summary> | ||
/// <param name="source">The source int</param> | ||
/// <returns>True if not zero</returns> | ||
public static bool ToBool(this int source) | ||
{ | ||
return source != 0; | ||
} | ||
} | ||
} |
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