1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 17:08:46 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Oliver Booth
7ea031bf3c
Merge 41ba8b5aad into 5ff7b68b37 2023-08-27 02:40:45 +00:00
4 changed files with 33 additions and 50 deletions

View File

@ -1,56 +1,50 @@
name: SonarCloud
name: Build
on:
push:
branches:
- main
workflow_dispatch:
pull_request:
types: [ opened, synchronize, reopened ]
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud Analysis
build:
name: Build
runs-on: windows-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 17
distribution: 'zulu'
java-version: 1.11
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v3
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
uses: actions/cache@v1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
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 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

@ -9,14 +9,11 @@ internal class CharTests
[Test]
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]
@ -29,7 +26,7 @@ internal class CharTests
}
[Test]
public void Repeat_ShouldReturnRepeatedCharacter_GivenValidCount()
public void RepeatShouldBeCorrect()
{
const string expected = "aaaaaaaaaa";
string actual = 'a'.Repeat(10);
@ -38,22 +35,22 @@ internal class CharTests
}
[Test]
public void Repeat_ShouldReturnSingleCharString_GivenCount1()
public void RepeatOneCountShouldBeLength1String()
{
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"));
}
[Test]
public void Repeat_ShouldReturnEmptyString_GivenCount0()
public void RepeatZeroCountShouldBeEmpty()
{
Assert.That('a'.Repeat(0), Is.EqualTo(string.Empty));
}
[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]
public void MDCodeBlock_ShouldReturnCodeBlockText_GivenText()
{
var expected = $"```{Environment.NewLine}Hello, world!{Environment.NewLine}```";
string actual = "Hello, world!".MDCodeBlock();
Assert.That(actual, Is.EqualTo(expected));
Assert.That("Hello, world!".MDCodeBlock(), Is.EqualTo($"```{Environment.NewLine}Hello, world!{Environment.NewLine}```"));
}
[Test]
public void MDCodeBlock_ShouldReturnCodeBlockText_GivenTextAndLanguage()
{
var expected = $"```csharp{Environment.NewLine}Hello, world!{Environment.NewLine}```";
string actual = "Hello, world!".MDCodeBlock("csharp");
Assert.That(actual, Is.EqualTo(expected));
Assert.That("Hello, world!".MDCodeBlock("csharp"), Is.EqualTo($"```csharp{Environment.NewLine}Hello, world!{Environment.NewLine}```"));
}
[Test]
@ -70,15 +64,12 @@ internal class MarkdownTests
[Test]
public void MDHeading_ShouldReturnHeadingText_GivenText()
{
Assert.Multiple(() =>
{
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(3), 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(6), 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(3), 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(6), Is.EqualTo("###### Hello, world!"));
}
[Test]

View File

@ -911,7 +911,8 @@ public static class StringExtensions
/// </summary>
/// <param name="value">The string to repeat.</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>
[Pure]
[MethodImpl(CompilerResources.MethodImplOptions)]