Skip to content

Commit

Permalink
🔀 Merge pull request #27 from LNA-DEV/dev
Browse files Browse the repository at this point in the history
Added new Object Method
  • Loading branch information
LNA-DEV committed Jan 14, 2023
2 parents ab22f75 + 7c7a05e commit c5bd3c9
Show file tree
Hide file tree
Showing 17 changed files with 352 additions and 232 deletions.
13 changes: 13 additions & 0 deletions .idea/.idea.CommonExtensions/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.CommonExtensions/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.CommonExtensions/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.CommonExtensions/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 39 additions & 40 deletions CommonExtensions.Test/CollectionsShould.cs
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();
}
}
43 changes: 22 additions & 21 deletions CommonExtensions.Test/CommonExtensions.Test.csproj
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>
109 changes: 54 additions & 55 deletions CommonExtensions.Test/DataTypesShould.cs
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; }
}
11 changes: 5 additions & 6 deletions CommonExtensions.Test/Models/TestDog.cs
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; }
}

0 comments on commit c5bd3c9

Please sign in to comment.