mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-25 15:48:47 +00:00
Compare commits
9 Commits
7ea031bf3c
...
b89e0df36f
Author | SHA1 | Date | |
---|---|---|---|
|
b89e0df36f | ||
74f957f0c2 | |||
1c58acd0a5 | |||
579a1d8c89 | |||
da08d23aee | |||
dc0b6abdc4 | |||
45ffd08dda | |||
fbd3e951c4 | |||
c6dbc4cebe |
30
.github/workflows/sonarcloud.yml
vendored
30
.github/workflows/sonarcloud.yml
vendored
@ -1,50 +1,56 @@
|
||||
name: Build
|
||||
name: SonarCloud
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
types: [ opened, synchronize, reopened ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
sonarcloud:
|
||||
name: SonarCloud Analysis
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 1.11
|
||||
java-version: 17
|
||||
distribution: 'zulu'
|
||||
|
||||
- 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@v1
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~\sonar\cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
|
||||
- name: Cache SonarCloud scanner
|
||||
id: cache-sonar-scanner
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v3
|
||||
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: |
|
||||
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
|
||||
.\.sonar\scanner\dotnet-sonarscanner begin /k:"oliverbooth_X10D" /o:"oliverbooth" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
|
||||
dotnet build --no-incremental
|
||||
dotnet dotcover test --dcReportType=HTML
|
||||
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
|
||||
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
||||
|
@ -9,11 +9,14 @@ internal class CharTests
|
||||
[Test]
|
||||
public void IsEmoji_ShouldReturnTrue_GivenBasicEmoji()
|
||||
{
|
||||
Assert.That('✂'.IsEmoji());
|
||||
Assert.That('✅'.IsEmoji());
|
||||
Assert.That('❎'.IsEmoji());
|
||||
Assert.That('➕'.IsEmoji());
|
||||
Assert.That('➖'.IsEmoji());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That('✂'.IsEmoji());
|
||||
Assert.That('✅'.IsEmoji());
|
||||
Assert.That('❎'.IsEmoji());
|
||||
Assert.That('➕'.IsEmoji());
|
||||
Assert.That('➖'.IsEmoji());
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -26,7 +29,7 @@ internal class CharTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RepeatShouldBeCorrect()
|
||||
public void Repeat_ShouldReturnRepeatedCharacter_GivenValidCount()
|
||||
{
|
||||
const string expected = "aaaaaaaaaa";
|
||||
string actual = 'a'.Repeat(10);
|
||||
@ -35,22 +38,22 @@ internal class CharTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RepeatOneCountShouldBeLength1String()
|
||||
public void Repeat_ShouldReturnSingleCharString_GivenCount1()
|
||||
{
|
||||
string repeated = 'a'.Repeat(1);
|
||||
Assert.That(repeated.Length, Is.EqualTo(1));
|
||||
Assert.That(repeated, Has.Length.EqualTo(1));
|
||||
Assert.That(repeated, Is.EqualTo("a"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RepeatZeroCountShouldBeEmpty()
|
||||
public void Repeat_ShouldReturnEmptyString_GivenCount0()
|
||||
{
|
||||
Assert.That('a'.Repeat(0), Is.EqualTo(string.Empty));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RepeatNegativeCountShouldThrow()
|
||||
public void Repeat_ShouldThrowArgumentOutOfRangeException_GivenNegativeCount()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => 'a'.Repeat(-1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => _ = 'a'.Repeat(-1));
|
||||
}
|
||||
}
|
||||
|
@ -39,13 +39,19 @@ internal class MarkdownTests
|
||||
[Test]
|
||||
public void MDCodeBlock_ShouldReturnCodeBlockText_GivenText()
|
||||
{
|
||||
Assert.That("Hello, world!".MDCodeBlock(), Is.EqualTo($"```{Environment.NewLine}Hello, world!{Environment.NewLine}```"));
|
||||
var expected = $"```{Environment.NewLine}Hello, world!{Environment.NewLine}```";
|
||||
string actual = "Hello, world!".MDCodeBlock();
|
||||
|
||||
Assert.That(actual, Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MDCodeBlock_ShouldReturnCodeBlockText_GivenTextAndLanguage()
|
||||
{
|
||||
Assert.That("Hello, world!".MDCodeBlock("csharp"), Is.EqualTo($"```csharp{Environment.NewLine}Hello, world!{Environment.NewLine}```"));
|
||||
var expected = $"```csharp{Environment.NewLine}Hello, world!{Environment.NewLine}```";
|
||||
string actual = "Hello, world!".MDCodeBlock("csharp");
|
||||
|
||||
Assert.That(actual, Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -64,12 +70,15 @@ internal class MarkdownTests
|
||||
[Test]
|
||||
public void MDHeading_ShouldReturnHeadingText_GivenText()
|
||||
{
|
||||
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.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!"));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -911,8 +911,7 @@ 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)]
|
||||
|
Loading…
Reference in New Issue
Block a user