Skip to content

Commit 9cf3c1a

Browse files
authored
Merge pull request #48 from droyad/Renovation
Renovation
2 parents 4ef0e91 + fd317dc commit 9cf3c1a

File tree

59 files changed

+1221
-1358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1221
-1358
lines changed

Assent.sln.DotSettings

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
3-
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
3+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
44
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<AssemblyName>Assent.Tests</AssemblyName>
66
<PackageId>Assent.Tests</PackageId>
7+
<LangVersion>latest</LangVersion>
8+
<Nullable>enable</Nullable>
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
710
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
811
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
912
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
1013
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1114
</PropertyGroup>
1215

1316
<ItemGroup>
14-
<ProjectReference Include="..\Assent\Assent.csproj" />
17+
<ProjectReference Include="..\Assent\Assent.csproj"/>
1518
</ItemGroup>
1619

1720
<ItemGroup>
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
19-
<PackageReference Include="NUnit" Version="3.13.3" />
20-
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
21-
<PackageReference Include="FluentAssertions" Version="6.7.0" />
22-
<PackageReference Include="NSubstitute" Version="4.4.0" />
23-
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
24-
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
21+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
22+
<PackageReference Include="NUnit" Version="4.4.0"/>
23+
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0"/>
24+
<PackageReference Include="FluentAssertions" Version="8.6.0"/>
25+
<PackageReference Include="NSubstitute" Version="5.3.0"/>
26+
<PackageReference Include="TestStack.BDDfy" Version="4.3.2"/>
27+
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0"/>
2528
</ItemGroup>
2629

2730
</Project>
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
11
using FluentAssertions;
22
using NUnit.Framework;
33

4-
namespace Assent.Tests
4+
namespace Assent.Tests;
5+
6+
public class DefaultStringComparerTests
57
{
6-
public class DefaultStringComparerTests
8+
[Test]
9+
public void LineEndingDifferencesResultInAFail()
710
{
8-
[Test]
9-
public void LineEndingDifferencesResultInAFail()
10-
{
11-
var compareResult = new DefaultStringComparer(false)
12-
.Compare("A\r\nb\nc", "A\nb\r\nc");
13-
compareResult.Passed.Should().BeFalse();
14-
compareResult.Error.Should().Contain("Strings differ only by line endings");
15-
}
11+
var compareResult = new DefaultStringComparer(false)
12+
.Compare("A\r\nb\nc", "A\nb\r\nc");
13+
compareResult.Passed.Should().BeFalse();
14+
compareResult.Error.Should().Contain("Strings differ only by line endings");
15+
}
1616

17-
[Test]
18-
public void LineEndingDifferencesResultInSuccessIfNormaliseLineEndingsIsTrue()
19-
{
20-
new DefaultStringComparer(true)
21-
.Compare("A\r\nb\nc", "A\nb\r\nc")
22-
.Passed
23-
.Should()
24-
.BeTrue();
25-
}
17+
[Test]
18+
public void LineEndingDifferencesResultInSuccessIfNormaliseLineEndingsIsTrue()
19+
{
20+
new DefaultStringComparer(true)
21+
.Compare("A\r\nb\nc", "A\nb\r\nc")
22+
.Passed
23+
.Should()
24+
.BeTrue();
25+
}
2626

27-
[Test]
28-
public void OneFileMissingNewLineAtEndOfFileResultInSuccessIfNormaliseLineEndingsIsTrue()
29-
{
30-
new DefaultStringComparer(true)
31-
.Compare("A\nb\nc\n", "A\nb\nc")
32-
.Passed
33-
.Should()
34-
.BeTrue();
35-
}
27+
[Test]
28+
public void OneFileMissingNewLineAtEndOfFileResultInSuccessIfNormaliseLineEndingsIsTrue()
29+
{
30+
new DefaultStringComparer(true)
31+
.Compare("A\nb\nc\n", "A\nb\nc")
32+
.Passed
33+
.Should()
34+
.BeTrue();
35+
}
3636

37-
[Test]
38-
public void OneFileMissingNewLineAtEndOfFileResultInAFail()
39-
{
40-
new DefaultStringComparer(false)
41-
.Compare("A\nb\nc\n", "A\nb\nc")
42-
.Passed
43-
.Should()
44-
.BeFalse();
45-
}
37+
[Test]
38+
public void OneFileMissingNewLineAtEndOfFileResultInAFail()
39+
{
40+
new DefaultStringComparer(false)
41+
.Compare("A\nb\nc\n", "A\nb\nc")
42+
.Passed
43+
.Should()
44+
.BeFalse();
4645
}
47-
}
46+
}

src/Assent.Tests/EndToEnd/ApprovedFileDoesNotMatchScenario.cs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,46 @@
22
using FluentAssertions;
33
using NSubstitute;
44

5-
namespace Assent.Tests.EndToEnd
5+
namespace Assent.Tests.EndToEnd;
6+
7+
public class ApprovedFileDoesNotMatchScenario : BaseScenario
68
{
7-
public class ApprovedFileDoesNotMatchScenario : BaseScenario
9+
private Action? action;
10+
private readonly string recievedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileDoesNotMatchScenario)}.{nameof(WhenTheTestIsRun)}.received.txt";
11+
private readonly string approvedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileDoesNotMatchScenario)}.{nameof(WhenTheTestIsRun)}.approved.txt";
12+
13+
public void AndGivenTheApprovedFileDoesNotMatch()
14+
{
15+
ReaderWriter.Files[approvedPath] = "Bar";
16+
}
17+
18+
public void WhenTheTestIsRun()
19+
{
20+
action = () => this.Assent("Foo", Configuration);
21+
}
22+
23+
public void ThenAnAssentExceptionIsThrown()
24+
{
25+
action.Should().Throw<AssentFailedException>().WithMessage("Strings differ at 0.\r\nReceived:Foo\r\nApproved:Bar");
26+
}
27+
28+
public void AndThenTheRecievedFileIsWritten()
29+
{
30+
ReaderWriter.Files.Keys.Should().Contain(recievedPath);
31+
}
32+
33+
public void AndThenAnApprovedFileIsNotChanged()
34+
{
35+
ReaderWriter.Files[approvedPath].Should().Be("Bar");
36+
}
37+
38+
public void AndThenTheReporterIsLaunched()
39+
{
40+
Reporter.Received().Report(recievedPath, approvedPath);
41+
}
42+
43+
public void AndThenTheRecievedFileWasCleanedUp()
844
{
9-
private Action _action;
10-
private readonly string _recievedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileDoesNotMatchScenario)}.{nameof(WhenTheTestIsRun)}.received.txt";
11-
private readonly string _approvedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileDoesNotMatchScenario)}.{nameof(WhenTheTestIsRun)}.approved.txt";
12-
13-
public void AndGivenTheApprovedFileDoesNotMatch()
14-
{
15-
ReaderWriter.Files[_approvedPath] = "Bar";
16-
}
17-
18-
public void WhenTheTestIsRun()
19-
{
20-
_action = () => this.Assent("Foo", Configuration);
21-
}
22-
23-
public void ThenAnAssentExceptionIsThrown()
24-
{
25-
_action.Should().Throw<AssentFailedException>().WithMessage("Strings differ at 0.\r\nReceived:Foo\r\nApproved:Bar");
26-
}
27-
28-
public void AndThenTheRecievedFileIsWritten()
29-
{
30-
ReaderWriter.Files.Keys.Should().Contain(_recievedPath);
31-
}
32-
33-
public void AndThenAnApprovedFileIsNotChanged()
34-
{
35-
ReaderWriter.Files[_approvedPath].Should().Be("Bar");
36-
}
37-
38-
public void AndThenTheReporterIsLaunched()
39-
{
40-
Reporter.Received().Report(_recievedPath, _approvedPath);
41-
}
42-
43-
public void AndThenTheRecievedFileWasCleanedUp()
44-
{
45-
ReaderWriter.Deleted.Should().Contain(_recievedPath);
46-
}
45+
ReaderWriter.Deleted.Should().Contain(recievedPath);
4746
}
4847
}

src/Assent.Tests/EndToEnd/ApprovedFileMatchesScenario.cs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,37 @@
22
using FluentAssertions;
33
using NSubstitute;
44

5-
namespace Assent.Tests.EndToEnd
5+
namespace Assent.Tests.EndToEnd;
6+
7+
public class ApprovedFileMatchesScenario : BaseScenario
68
{
7-
public class ApprovedFileMatchesScenario : BaseScenario
9+
private Action? action;
10+
private readonly string recievedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileMatchesScenario)}.{nameof(WhenTheTestIsRun)}.received.txt";
11+
private readonly string approvedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileMatchesScenario)}.{nameof(WhenTheTestIsRun)}.approved.txt";
12+
13+
public void AndGivenTheApprovedFileDoesNotMatch()
14+
{
15+
ReaderWriter.Files[approvedPath] = "Foo";
16+
}
17+
18+
public void WhenTheTestIsRun()
19+
{
20+
action = () => this.Assent("Foo", Configuration);
21+
}
22+
23+
public void ThenAnExceptionIsNotThrown()
824
{
9-
private Action _action;
10-
private readonly string _recievedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileMatchesScenario)}.{nameof(WhenTheTestIsRun)}.received.txt";
11-
private readonly string _approvedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(ApprovedFileMatchesScenario)}.{nameof(WhenTheTestIsRun)}.approved.txt";
12-
13-
public void AndGivenTheApprovedFileDoesNotMatch()
14-
{
15-
ReaderWriter.Files[_approvedPath] = "Foo";
16-
}
17-
18-
public void WhenTheTestIsRun()
19-
{
20-
_action = () => this.Assent("Foo", Configuration);
21-
}
22-
23-
public void ThenAnExceptionIsNotThrown()
24-
{
25-
_action.Should().NotThrow();
26-
}
27-
28-
public void AndThenTheRecievedFileIsNotWritten()
29-
{
30-
ReaderWriter.Files.Keys.Should().NotContain(_recievedPath);
31-
}
32-
33-
public void AndThenTheReporterIsLaunched()
34-
{
35-
Reporter.DidNotReceiveWithAnyArgs().Report(_recievedPath, _approvedPath);
36-
}
25+
action.Should().NotThrow();
26+
}
3727

28+
public void AndThenTheRecievedFileIsNotWritten()
29+
{
30+
ReaderWriter.Files.Keys.Should().NotContain(recievedPath);
3831
}
32+
33+
public void AndThenTheReporterIsLaunched()
34+
{
35+
Reporter.DidNotReceiveWithAnyArgs().Report(recievedPath, approvedPath);
36+
}
37+
3938
}

src/Assent.Tests/EndToEnd/AssentNonInterativeVariablePreventsReporterFromRunningScenario.cs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,36 @@
33
using NSubstitute;
44
using NUnit.Framework;
55

6-
namespace Assent.Tests.EndToEnd
6+
namespace Assent.Tests.EndToEnd;
7+
8+
public class AssentNonInterativeVariablePreventsReporterFromRunningScenario : BaseScenario
79
{
8-
public class AssentNonInterativeVariablePreventsReporterFromRunningScenario : BaseScenario
9-
{
10-
private Action _action;
11-
private readonly string _recievedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(AssentNonInterativeVariablePreventsReporterFromRunningScenario)}.{nameof(WhenTheTestIsRun)}.received.txt";
10+
private Action? action;
11+
private readonly string recievedPath = $@"{GetTestDirectory()}\EndToEnd\{nameof(AssentNonInterativeVariablePreventsReporterFromRunningScenario)}.{nameof(WhenTheTestIsRun)}.received.txt";
1212

13-
public void AndGivenTheAssentNonInteractiveEnvironmentVariableIsSetToTrue()
14-
{
15-
Environment.SetEnvironmentVariable("AssentNonInteractive", "TrUe");
16-
}
13+
public void AndGivenTheAssentNonInteractiveEnvironmentVariableIsSetToTrue()
14+
{
15+
Environment.SetEnvironmentVariable("AssentNonInteractive", "TrUe");
16+
}
1717

18-
public void WhenTheTestIsRun()
19-
{
20-
_action = () => this.Assent("Foo", Configuration);
21-
}
18+
public void WhenTheTestIsRun()
19+
{
20+
action = () => this.Assent("Foo", Configuration);
21+
}
2222

23-
public void ThenAnAssentExceptionIsThrown()
24-
{
25-
_action.Should().Throw<AssentFailedException>().WithMessage("Strings differ");
26-
}
23+
public void ThenAnAssentExceptionIsThrown()
24+
{
25+
action.Should().Throw<AssentFailedException>().WithMessage("Strings differ");
26+
}
2727

28-
public void AndThenTheRecievedFileIsWritten()
29-
{
30-
ReaderWriter.Files.Keys.Should().Contain(_recievedPath);
31-
}
28+
public void AndThenTheRecievedFileIsWritten()
29+
{
30+
ReaderWriter.Files.Keys.Should().Contain(recievedPath);
31+
}
3232

33-
[TearDown]
34-
public void TearDown()
35-
{
36-
Environment.SetEnvironmentVariable("AssentNonInteractive", "");
37-
}
33+
[TearDown]
34+
public void TearDown()
35+
{
36+
Environment.SetEnvironmentVariable("AssentNonInteractive", "");
3837
}
39-
}
38+
}

0 commit comments

Comments
 (0)