-
Notifications
You must be signed in to change notification settings - Fork 1
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 #27 from LNA-DEV/dev
Added new Object Method
- Loading branch information
Showing
17 changed files
with
352 additions
and
232 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,53 +1,52 @@ | ||
using Shouldly; | ||
|
||
namespace CommonExtensions.Test | ||
namespace CommonExtensions.Test; | ||
|
||
public class CollectionsShould | ||
{ | ||
public class CollectionsShould | ||
[Fact] | ||
public void IsNullOrEmpty() | ||
{ | ||
[Fact] | ||
public void IsNullOrEmpty() | ||
// Arrange | ||
List<string> emptyList = new(); | ||
List<string>? nullList = null; | ||
List<string> fullList = new() | ||
{ | ||
// Arrange | ||
List<string> emptyList = new(); | ||
List<string>? nullList = null; | ||
List<string> fullList = new() | ||
{ | ||
"Blub", | ||
"Hello World" | ||
}; | ||
"Blub", | ||
"Hello World" | ||
}; | ||
|
||
// Act | ||
bool isEmpty = emptyList.IsNullOrEmpty(); | ||
bool isNull = nullList.IsNullOrEmpty(); | ||
bool isNotNullOrEmpty = fullList.IsNullOrEmpty(); | ||
// Act | ||
var isEmpty = emptyList.IsNullOrEmpty(); | ||
var isNull = nullList.IsNullOrEmpty(); | ||
var isNotNullOrEmpty = fullList.IsNullOrEmpty(); | ||
|
||
// Assert | ||
isEmpty.ShouldBeTrue(); | ||
isNull.ShouldBeTrue(); | ||
isNotNullOrEmpty.ShouldBeFalse(); | ||
} | ||
// Assert | ||
isEmpty.ShouldBeTrue(); | ||
isNull.ShouldBeTrue(); | ||
isNotNullOrEmpty.ShouldBeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void IsNotNullOrEmpty() | ||
[Fact] | ||
public void IsNotNullOrEmpty() | ||
{ | ||
// Arrange | ||
List<string> emptyList = new(); | ||
List<string>? nullList = null; | ||
List<string> fullList = new() | ||
{ | ||
// Arrange | ||
List<string> emptyList = new(); | ||
List<string>? nullList = null; | ||
List<string> fullList = new() | ||
{ | ||
"Blub", | ||
"Hello World" | ||
}; | ||
"Blub", | ||
"Hello World" | ||
}; | ||
|
||
// Act | ||
bool isEmpty = emptyList.IsNotNullOrEmpty(); | ||
bool isNull = nullList.IsNotNullOrEmpty(); | ||
bool isNullOrEmpty = fullList.IsNotNullOrEmpty(); | ||
// Act | ||
var isEmpty = emptyList.IsNotNullOrEmpty(); | ||
var isNull = nullList.IsNotNullOrEmpty(); | ||
var isNullOrEmpty = fullList.IsNotNullOrEmpty(); | ||
|
||
// Assert | ||
isEmpty.ShouldBeFalse(); | ||
isNull.ShouldBeFalse(); | ||
isNullOrEmpty.ShouldBeTrue(); | ||
} | ||
// Assert | ||
isEmpty.ShouldBeFalse(); | ||
isNull.ShouldBeFalse(); | ||
isNullOrEmpty.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 |
---|---|---|
@@ -1,28 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> | ||
<PackageReference Include="Shouldly" Version="4.1.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CommonExtensions\CommonExtensions.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\CommonExtensions\CommonExtensions.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -1,68 +1,67 @@ | ||
using Shouldly; | ||
|
||
namespace CommonExtensions.Test | ||
namespace CommonExtensions.Test; | ||
|
||
public class DataTypesShould | ||
{ | ||
public class DataTypesShould | ||
[InlineData(true, false)] | ||
[InlineData(true, 0)] | ||
[InlineData(true, 0.0)] | ||
[InlineData(false, true)] | ||
[InlineData(false, 10)] | ||
[InlineData(false, 0.33)] | ||
[Theory] | ||
public void EvaluateSimpleTypes<T>(bool expected, T value) | ||
{ | ||
[InlineData(true, false)] | ||
[InlineData(true, 0)] | ||
[InlineData(true, 0.0)] | ||
[InlineData(false, true)] | ||
[InlineData(false, 10)] | ||
[InlineData(false, 0.33)] | ||
[Theory] | ||
public void EvaluateSimpleTypes<T>(bool expected, T value) | ||
{ | ||
value.IsDefault().ShouldBe(expected); | ||
} | ||
value.IsDefault().ShouldBe(expected); | ||
} | ||
|
||
[InlineData(true, null, null, null)] | ||
[InlineData(false, 10, true, 0.333)] | ||
[InlineData(false, 0, false, 0.0)] | ||
[Theory] | ||
public void EvaluateNullableTypes(bool expected, int? intNull, bool? boolNull, double? doubleNull) | ||
{ | ||
intNull.IsDefault().ShouldBe(expected); | ||
boolNull.IsDefault().ShouldBe(expected); | ||
doubleNull.IsDefault().ShouldBe(expected); | ||
} | ||
[InlineData(true, null, null, null)] | ||
[InlineData(false, 10, true, 0.333)] | ||
[InlineData(false, 0, false, 0.0)] | ||
[Theory] | ||
public void EvaluateNullableTypes(bool expected, int? intNull, bool? boolNull, double? doubleNull) | ||
{ | ||
intNull.IsDefault().ShouldBe(expected); | ||
boolNull.IsDefault().ShouldBe(expected); | ||
doubleNull.IsDefault().ShouldBe(expected); | ||
} | ||
|
||
[InlineData(false, "SomeStringValue")] | ||
[InlineData(true, null)] | ||
[Theory] | ||
public void EvaluateStringTypes(bool expected, string value) | ||
{ | ||
value.IsDefault().ShouldBe(expected); | ||
} | ||
[InlineData(false, "SomeStringValue")] | ||
[InlineData(true, null)] | ||
[Theory] | ||
public void EvaluateStringTypes(bool expected, string value) | ||
{ | ||
value.IsDefault().ShouldBe(expected); | ||
} | ||
|
||
[Fact] | ||
public void EvaluateComplexTypes() | ||
{ | ||
Company company = new Company(); | ||
[Fact] | ||
public void EvaluateComplexTypes() | ||
{ | ||
var company = new Company(); | ||
|
||
company.Boss.IsDefault().ShouldBeTrue(); | ||
company.Employees.IsDefault().ShouldBeTrue(); | ||
company.Boss.IsDefault().ShouldBeTrue(); | ||
company.Employees.IsDefault().ShouldBeTrue(); | ||
|
||
company.Boss = new Person() | ||
{ | ||
Name = "Tom" | ||
}; | ||
company.Employees = new Person[] { company.Boss, new Person() { Name = "Fred" } }; | ||
company.Boss = new Person | ||
{ | ||
Name = "Tom" | ||
}; | ||
company.Employees = new[] { company.Boss, new() { Name = "Fred" } }; | ||
|
||
company.Boss.IsDefault().ShouldBeFalse(); | ||
company.Employees.IsDefault().ShouldBeFalse(); | ||
} | ||
company.Boss.IsDefault().ShouldBeFalse(); | ||
company.Employees.IsDefault().ShouldBeFalse(); | ||
} | ||
} | ||
|
||
//Classes for Testing | ||
public class Company | ||
{ | ||
public Person? Boss { get; set; } | ||
public Person[]? Employees { get; set; } | ||
} | ||
|
||
public class Person | ||
{ | ||
public string? Name { get; set; } | ||
} | ||
//Classes for Testing | ||
public class Company | ||
{ | ||
public Person? Boss { get; set; } | ||
public Person[]? Employees { get; set; } | ||
} | ||
|
||
public class Person | ||
{ | ||
public string? Name { get; set; } | ||
} |
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
namespace CommonExtensions.Test.Models | ||
namespace CommonExtensions.Test.Models; | ||
|
||
public class TestDog | ||
{ | ||
public class TestDog | ||
{ | ||
public string? Name { get; set; } | ||
public int LegCount { get; set; } | ||
} | ||
public string? Name { get; set; } | ||
public int LegCount { get; set; } | ||
} |
Oops, something went wrong.