-
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 #11 from calebjenkins/develop
Version bump - New IList AddRange extension method
- Loading branch information
Showing
15 changed files
with
218 additions
and
69 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
on: | ||
push: | ||
branches: | ||
- '!develop' | ||
- '!main' | ||
paths-ignore: | ||
- '**.md' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0.x' | ||
|
||
- name: Package Restore | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release | ||
|
||
- name: Test | ||
#run: dotnet test --configuration Release --no-build | ||
run: dotnet test --configuration Release --no-build --filter 'FullyQualifiedName!~BDD_Specs' | ||
|
||
#- name: Run SpecFlow Tests | ||
# uses: cryptic-wizard/run-specflow-tests@v1.3.1 | ||
# with: | ||
# test-assembly-path: src/BDD/BDD_Specs/BDD_Specs/bin/Release/net6.0 | ||
# test-assembly-dll: BDD_Specs.dll | ||
# output-html: BDD_SpecResults.html | ||
# no-build: true | ||
# upload-artifact: true | ||
|
||
- name: Echo Branch Name | ||
run: echo "Branch name is $GITHUB_REF_NAME " | ||
|
||
- name: Get version | ||
id: get_version | ||
uses: greenygh0st/net-proj-release-version@v1 | ||
with: | ||
# Filepath of the *.csproj file, relative to root of repository | ||
PROJ_FILE: src/Extensions/Extensions.csproj | ||
|
||
# env: | ||
# RELEASE_VERSION: ${{ steps.get_version.outputs.RELEASE_VERSION }} | ||
|
||
|
||
- name: Show Release Version | ||
run: echo "Release Version is ${{steps.get_version.outputs.RELEASE_VERSION}}" | ||
|
||
- name: Set Release Version | ||
run: echo "getting version" | ||
|
||
env: | ||
RELEASE_VERSION: steps.get_version.outputs.RELEASE_VERSION | ||
|
||
- name: Print new build number | ||
run: echo "Build number is $GITHUB_RUN_NUMBER " | ||
|
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
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,36 @@ | ||
| ||
namespace ExtensionTests; | ||
|
||
using Calebs.Extensions; | ||
|
||
public class ListExtensionTests | ||
{ | ||
[Fact] | ||
public void ShouldCombineLists() | ||
{ | ||
IList<string> l1 = new List<string>() | ||
{ | ||
"One", | ||
"two", | ||
"three" | ||
}; | ||
|
||
IList<string> l2 = new List<string>() | ||
{ | ||
"four", | ||
"five" | ||
}; | ||
|
||
l1.Count.Should().Be(3); | ||
l2.Count.Should().Be(2); | ||
|
||
l1.AddRange<string>(l2); | ||
|
||
l1.Count.Should().Be(5); | ||
|
||
l2.Count.Should().Be(2); | ||
} | ||
|
||
|
||
} | ||
|
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
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,18 +1,23 @@ | ||
| ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newt = Newtonsoft.Json; | ||
using Conv = Newtonsoft.Json.Converters; | ||
|
||
|
||
namespace Calebs.Extensions; | ||
|
||
public static class JsonExtensions | ||
{ | ||
public static T FromJson<T>(this string json) | ||
{ | ||
return JsonConvert.DeserializeObject<T>(json); | ||
T result = default(T); | ||
result = Newt.JsonConvert.DeserializeObject<T>(json); | ||
return result; | ||
} | ||
|
||
public static string ToJson(this object o) | ||
{ | ||
return JsonConvert.SerializeObject(o, new StringEnumConverter()); | ||
var result = string.Empty; | ||
result = Newt.JsonConvert.SerializeObject(o, new Conv.StringEnumConverter()); | ||
return result; | ||
} | ||
} |
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,19 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Calebs.Extensions; | ||
|
||
public static class ListExtensions | ||
{ | ||
public static string ToDelimitedList(this List<string> list, string delimiter) | ||
{ | ||
return string.Join(delimiter, list.ToArray()); | ||
} | ||
|
||
public static void ToUpper(this List<string> list) | ||
{ | ||
for (var i = 0; i < list.Count; i++) | ||
{ | ||
list[i] = list[i].ToUpper(); | ||
} | ||
} | ||
} | ||
{ | ||
public static string ToDelimitedList(this List<string> list, string delimiter) | ||
{ | ||
return string.Join(delimiter, list.ToArray()); | ||
} | ||
|
||
public static void ToUpper(this IList<string> list) | ||
{ | ||
for (var i = 0; i < list.Count; i++) | ||
{ | ||
list[i] = list[i].ToUpper(); | ||
} | ||
} | ||
|
||
public static void AddRange<T>(this IList<T> list, IEnumerable<T> items) | ||
{ | ||
if (list == null) throw new ArgumentNullException(nameof(list)); | ||
if (items == null) throw new ArgumentNullException(nameof(items)); | ||
|
||
if (list is List<T> asList) | ||
{ | ||
asList.AddRange(items); | ||
} | ||
else | ||
{ | ||
foreach (var item in items) | ||
{ | ||
list.Add(item); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.