-
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.
Showing
117 changed files
with
75,754 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,4 +395,5 @@ FodyWeavers.xsd | |
*.msp | ||
|
||
# JetBrains Rider | ||
.idea/ | ||
*.sln.iml |
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,5 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir> | ||
</PropertyGroup> | ||
</Project> |
11 changes: 11 additions & 0 deletions
11
src/ProjectPatterns/Archetypes/SharedLibraryArchetype.props
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
|
||
<Import Project="../BaseProject.props" /> | ||
<Import Project="../Patterns/LoggingAbstractionPattern.props" /> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Ardalis.GuardClauses" Version="4.0.1" /> | ||
</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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<GenerateDocumentation Condition="'$(GenerateDocumentation)' == ''">false</GenerateDocumentation> | ||
<IsPackable>false</IsPackable> | ||
<NoWarn>1701;1702;1591;</NoWarn> | ||
<CodeAnalysisRuleSet>$(SolutionDir)/Stylecop_UnitTests.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
|
||
<Import Project="../BaseProject.props" /> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Bogus" Version="34.0.1" /> | ||
<PackageReference Include="NSubstitute" Version="4.2.2" /> | ||
<PackageReference Include="nunit" Version="3.13.2" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" /> | ||
<PackageReference Include="FluentAssertions" Version="6.2.0" /> | ||
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" /> | ||
<PackageReference Include="System.Net.Http" Version="4.3.4" /> | ||
</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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
<PropertyGroup> | ||
<TargetFramework Condition="'$(TargetFramework)' == ''">net6.0</TargetFramework> | ||
<RootNamespace>$(MSBuildProjectName)</RootNamespace> | ||
<Configurations>Debug;Release</Configurations> | ||
<NeutralLanguage>en-GB</NeutralLanguage> | ||
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(SolutionDir)/Stylecop.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
|
||
<!-- Set assembly properties --> | ||
<PropertyGroup> | ||
<Company Condition="'$(Company)' == ''">Bugail Consulting Ltd</Company> | ||
<Copyright Condition="'$(Copyright)' == ''">Copyright © 2023 $(Company)</Copyright> | ||
<Authors Condition="'$(Authors)' == ''">$(Company)</Authors> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Update="IDisposableAnalyzers" Version="4.0.1"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="$(SolutionDir)\stylecop.json" Link="stylecop.json" /> | ||
</ItemGroup> | ||
|
||
<!-- Enable documentation generation --> | ||
<PropertyGroup> | ||
<GenerateDocumentationFile Condition="'$(GenerateDocumentationFile)' == ''">true</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
|
||
</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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" /> | ||
</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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Serilog" Version="2.10.0" /> | ||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> | ||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> | ||
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.1.0"/> | ||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0"/> | ||
</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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RuleSet Name="Name" Description="Description" ToolsVersion="16.0"> | ||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> | ||
<!-- <Rule Id="SA1028" Action="None" /> --> | ||
<Rule Id="SA1101" Action="None" /> | ||
<Rule Id="SA1413" Action="None" /> | ||
<Rule Id="SA1503" Action="None" /> | ||
<Rule Id="SA1627" Action="None" /> | ||
<Rule Id="SA1629" Action="None" /> | ||
<Rule Id="SA1633" Action="None" /> | ||
<Rule Id="SA1635" Action="None" /> | ||
<Rule Id="SA1636" Action="None" /> | ||
<Rule Id="SA1638" Action="None" /> | ||
<Rule Id="SA1640" Action="None" /> | ||
<Rule Id="SA1641" Action="None" /> | ||
<Rule Id="SA1650" Action="None" /> | ||
<Rule Id="CA2254" Action="None" /> | ||
</Rules> | ||
</RuleSet> |
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RuleSet Name="Name" Description="Description" ToolsVersion="16.0"> | ||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> | ||
<Rule Id="SA1101" Action="None" /> | ||
<Rule Id="SA1413" Action="None" /> | ||
<Rule Id="SA1503" Action="Info" /> | ||
<Rule Id="SA1600" Action="None" /> | ||
<Rule Id="SA1627" Action="Info" /> | ||
<Rule Id="SA1629" Action="None" /> | ||
<Rule Id="SA1633" Action="None" /> | ||
<Rule Id="SA1650" Action="Info" /> | ||
<Rule Id="CA2254" Action="None" /> | ||
</Rules> | ||
</RuleSet> |
68 changes: 68 additions & 0 deletions
68
src/Tests/UL.Core.Tests/Extensions/IntegerExtensionsTests.cs
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,68 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="IntegerExtensions.cs" company="Bugail Consulting Ltd"> | ||
// Copyright 2023 (c) Bugail Consulting Ltd. All rights reserved. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace UL.Core.Tests | ||
{ | ||
using System; | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
using UL.Core.Extensions; | ||
|
||
public class IntegerExtensionsTests | ||
{ | ||
[TestCase(1, 1, true)] | ||
[TestCase(0, 1, true)] | ||
[TestCase(2, 3, false)] | ||
[TestCase(15, 3, true)] | ||
[TestCase(15, 5, true)] | ||
[TestCase(16, 3, false)] | ||
[TestCase(16, 5, false)] | ||
[TestCase(16, 5, false)] | ||
public void IsDivisableBy_ValidValues_ReturnsCorrectResult(int value, int divider, bool expectedResult) | ||
{ | ||
// Arrange | ||
|
||
// Act | ||
var result = value.IsDivisableBy(divider); | ||
|
||
// Assert | ||
result.Should().Be(expectedResult); | ||
} | ||
|
||
[TestCase(0, 1)] | ||
[TestCase(1, 1)] | ||
[TestCase(2, 2)] | ||
[TestCase(3, 6)] | ||
[TestCase(4, 24)] | ||
[TestCase(5, 120)] | ||
[TestCase(6, 720)] | ||
public void Factorial_PositiveValues_ReturnsValidResult(int value, int expectedResult) | ||
{ | ||
// Act | ||
var result = value.Factorial(); | ||
|
||
// Assert | ||
result.Should().Be(expectedResult); | ||
} | ||
|
||
[TestCase(-1)] | ||
[TestCase(-2)] | ||
[TestCase(-3)] | ||
[TestCase(-4)] | ||
[TestCase(-5)] | ||
[TestCase(-6)] | ||
public void Factorial_NegativeValue_ThrowsException(int value) | ||
{ | ||
// Act | ||
var result = () => value.Factorial(); | ||
|
||
// Assert | ||
result.Should() | ||
.Throw<ArgumentException>() | ||
.WithMessage("*Factorial value must be positive*"); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Tests/UL.Core.Tests/Extensions/StringExtensionsTests.cs
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,26 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="StringExtensionsTests.cs" company="Bugail Consulting Ltd"> | ||
// Copyright 2023 (c) Bugail Consulting Ltd. All rights reserved. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace UL.Core.Tests | ||
{ | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
using UL.Core.Extensions; | ||
|
||
[TestFixture] | ||
public class StringExtensionsTests | ||
{ | ||
[TestCase("", true)] | ||
public void IsNumeric_ValidString_ReturnsCorrectResult(string value, bool expectedResult) | ||
{ | ||
// Act | ||
var result = value.IsNumeric(); | ||
|
||
// Assert | ||
result.Should().Be(expectedResult); | ||
} | ||
} | ||
} |
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Import Project="$(SolutionDir)/ProjectPatterns/Archetypes/UnitTestingArchetype.props" /> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\UL.Core\UL.Core.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="FactoralServiceTests.cs" company="Bugail Consulting Ltd"> | ||
// Copyright 2023 (c) Bugail Consulting Ltd. All rights reserved. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace UL.Services.Tests | ||
{ | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class FactoralServiceTests | ||
{ | ||
private FactorialService target; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
this.target = new FactorialService(); | ||
} | ||
|
||
[TestCase(3, 6)] | ||
public void Test(int value, int expectedResult) | ||
{ | ||
// Act | ||
var result = this.target.Calculate(value); | ||
|
||
// Assert | ||
result.Should().Be(expectedResult); | ||
} | ||
} | ||
} |
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,80 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="FizzBuzzServiceTests.cs" company="Bugail Consulting Ltd"> | ||
// Copyright 2023 (c) Bugail Consulting Ltd. All rights reserved. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace UL.Services.Tests | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Logging; | ||
using NSubstitute; | ||
using NUnit.Framework; | ||
using UL.Abstractions.Interfaces; | ||
using Ul.Services.Strategies; | ||
|
||
[TestFixture] | ||
public class FizzBuzzServiceTests | ||
{ | ||
private List<IFizzBuzzStrategy> stategies; | ||
private FizzBuzzService target; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
this.stategies = new List<IFizzBuzzStrategy> | ||
{ | ||
new FizzStrategy(), | ||
new BuzzStrategy() | ||
}; | ||
|
||
this.target = new FizzBuzzService(this.stategies); | ||
} | ||
|
||
[Test] | ||
public void GetFizzBuzzList_ValidCollection_ReturnsValidResults() | ||
{ | ||
// Arrange | ||
var list = Enumerable.Range(1, 100).ToList(); | ||
|
||
// Act | ||
var results = this.target.GetFizzBuzzList(list); | ||
|
||
// Assert | ||
results.ToList().Count.Should().Be(100); | ||
} | ||
|
||
[Test] | ||
public void GetFizzBuzzList_NullCollection_ThrowsException() | ||
{ | ||
// Arrange | ||
List<int> collection = null; | ||
|
||
// Act | ||
Func<IEnumerable<string>> action = () => this.target.GetFizzBuzzList(collection); | ||
|
||
// Assert | ||
action.Should() | ||
.Throw<ArgumentNullException>() | ||
.WithMessage("*collection*"); | ||
} | ||
|
||
[Test] | ||
public void GetFizzBuzzList_EmptyCollection_ThrowsException() | ||
{ | ||
// Arrange | ||
List<int> collection = new List<int>(); | ||
|
||
// Act | ||
Func<IEnumerable<string>> action = () => this.target.GetFizzBuzzList(collection); | ||
|
||
// Assert | ||
action.Should() | ||
.Throw<ArgumentException>() | ||
.WithMessage("*collection*"); | ||
} | ||
} | ||
} |
Oops, something went wrong.