Compare commits

..

No commits in common. "74f957f0c2379a4559b4b063424a670e0c9214b2" and "41ba8b5aada8dd0ad548ffa0de99589cb0a8ba7b" have entirely different histories.

4 changed files with 33 additions and 50 deletions

View File

@ -1,56 +1,50 @@
name: SonarCloud name: Build
on: on:
push: push:
branches: branches:
- main - main
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
types: [ opened, synchronize, reopened ] types: [opened, synchronize, reopened]
jobs: jobs:
sonarcloud: build:
name: SonarCloud Analysis name: Build
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Set up JDK 17 - name: Set up JDK 11
uses: actions/setup-java@v3 uses: actions/setup-java@v1
with: with:
java-version: 17 java-version: 1.11
distribution: 'zulu'
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages - name: Cache SonarCloud packages
uses: actions/cache@v3 uses: actions/cache@v1
with: with:
path: ~\sonar\cache path: ~\sonar\cache
key: ${{ runner.os }}-sonar key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner - name: Cache SonarCloud scanner
id: cache-sonar-scanner id: cache-sonar-scanner
uses: actions/cache@v3 uses: actions/cache@v1
with: with:
path: .\.sonar\scanner path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner - name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell shell: powershell
run: | run: |
New-Item -Path .\.sonar\scanner -ItemType Directory New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze - name: Build and analyze
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell shell: powershell
run: | run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"oliverbooth_X10D" /o:"oliverbooth" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet tool install JetBrains.dotCover.GlobalTool -g
.\.sonar\scanner\dotnet-sonarscanner begin /k:"oliverbooth_X10D" /o:"oliverbooth" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html
dotnet build --no-incremental dotnet build --no-incremental
dotnet dotcover test --dcReportType=HTML dotnet dotcover test --dcReportType=HTML
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

View File

@ -8,15 +8,12 @@ internal class CharTests
{ {
[Test] [Test]
public void IsEmoji_ShouldReturnTrue_GivenBasicEmoji() public void IsEmoji_ShouldReturnTrue_GivenBasicEmoji()
{
Assert.Multiple(() =>
{ {
Assert.That('✂'.IsEmoji()); Assert.That('✂'.IsEmoji());
Assert.That('✅'.IsEmoji()); Assert.That('✅'.IsEmoji());
Assert.That('❎'.IsEmoji()); Assert.That('❎'.IsEmoji());
Assert.That(''.IsEmoji()); Assert.That(''.IsEmoji());
Assert.That(''.IsEmoji()); Assert.That(''.IsEmoji());
});
} }
[Test] [Test]
@ -29,7 +26,7 @@ internal class CharTests
} }
[Test] [Test]
public void Repeat_ShouldReturnRepeatedCharacter_GivenValidCount() public void RepeatShouldBeCorrect()
{ {
const string expected = "aaaaaaaaaa"; const string expected = "aaaaaaaaaa";
string actual = 'a'.Repeat(10); string actual = 'a'.Repeat(10);
@ -38,22 +35,22 @@ internal class CharTests
} }
[Test] [Test]
public void Repeat_ShouldReturnSingleCharString_GivenCount1() public void RepeatOneCountShouldBeLength1String()
{ {
string repeated = 'a'.Repeat(1); string repeated = 'a'.Repeat(1);
Assert.That(repeated, Has.Length.EqualTo(1)); Assert.That(repeated.Length, Is.EqualTo(1));
Assert.That(repeated, Is.EqualTo("a")); Assert.That(repeated, Is.EqualTo("a"));
} }
[Test] [Test]
public void Repeat_ShouldReturnEmptyString_GivenCount0() public void RepeatZeroCountShouldBeEmpty()
{ {
Assert.That('a'.Repeat(0), Is.EqualTo(string.Empty)); Assert.That('a'.Repeat(0), Is.EqualTo(string.Empty));
} }
[Test] [Test]
public void Repeat_ShouldThrowArgumentOutOfRangeException_GivenNegativeCount() public void RepeatNegativeCountShouldThrow()
{ {
Assert.Throws<ArgumentOutOfRangeException>(() => _ = 'a'.Repeat(-1)); Assert.Throws<ArgumentOutOfRangeException>(() => 'a'.Repeat(-1));
} }
} }

View File

@ -39,19 +39,13 @@ internal class MarkdownTests
[Test] [Test]
public void MDCodeBlock_ShouldReturnCodeBlockText_GivenText() public void MDCodeBlock_ShouldReturnCodeBlockText_GivenText()
{ {
var expected = $"```{Environment.NewLine}Hello, world!{Environment.NewLine}```"; Assert.That("Hello, world!".MDCodeBlock(), Is.EqualTo($"```{Environment.NewLine}Hello, world!{Environment.NewLine}```"));
string actual = "Hello, world!".MDCodeBlock();
Assert.That(actual, Is.EqualTo(expected));
} }
[Test] [Test]
public void MDCodeBlock_ShouldReturnCodeBlockText_GivenTextAndLanguage() public void MDCodeBlock_ShouldReturnCodeBlockText_GivenTextAndLanguage()
{ {
var expected = $"```csharp{Environment.NewLine}Hello, world!{Environment.NewLine}```"; Assert.That("Hello, world!".MDCodeBlock("csharp"), Is.EqualTo($"```csharp{Environment.NewLine}Hello, world!{Environment.NewLine}```"));
string actual = "Hello, world!".MDCodeBlock("csharp");
Assert.That(actual, Is.EqualTo(expected));
} }
[Test] [Test]
@ -69,8 +63,6 @@ internal class MarkdownTests
[Test] [Test]
public void MDHeading_ShouldReturnHeadingText_GivenText() public void MDHeading_ShouldReturnHeadingText_GivenText()
{
Assert.Multiple(() =>
{ {
Assert.That("Hello, world!".MDHeading(1), Is.EqualTo("# Hello, world!")); Assert.That("Hello, world!".MDHeading(1), Is.EqualTo("# Hello, world!"));
Assert.That("Hello, world!".MDHeading(2), Is.EqualTo("## Hello, world!")); Assert.That("Hello, world!".MDHeading(2), Is.EqualTo("## Hello, world!"));
@ -78,7 +70,6 @@ internal class MarkdownTests
Assert.That("Hello, world!".MDHeading(4), Is.EqualTo("#### Hello, world!")); Assert.That("Hello, world!".MDHeading(4), Is.EqualTo("#### Hello, world!"));
Assert.That("Hello, world!".MDHeading(5), Is.EqualTo("##### Hello, world!")); Assert.That("Hello, world!".MDHeading(5), Is.EqualTo("##### Hello, world!"));
Assert.That("Hello, world!".MDHeading(6), Is.EqualTo("###### Hello, world!")); Assert.That("Hello, world!".MDHeading(6), Is.EqualTo("###### Hello, world!"));
});
} }
[Test] [Test]

View File

@ -911,7 +911,8 @@ public static class StringExtensions
/// </summary> /// </summary>
/// <param name="value">The string to repeat.</param> /// <param name="value">The string to repeat.</param>
/// <param name="count">The repeat count.</param> /// <param name="count">The repeat count.</param>
/// <returns>A string containing <paramref name="value" /> repeated <paramref name="count" /> times.</returns> /// <returns>A string containing <paramref name="value" /> repeated <paramref name="count" /> times.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
[Pure] [Pure]
[MethodImpl(CompilerResources.MethodImplOptions)] [MethodImpl(CompilerResources.MethodImplOptions)]