Skip to content

Commit dc382f7

Browse files
committed
(#2893) Update tests to use to FluentAssertions style
This updates tests to use new ways of writing assertions that are available in FluentAssertions but where not in Should
1 parent b53b46f commit dc382f7

25 files changed

+942
-1917
lines changed

src/chocolatey.tests.integration/infrastructure.app/builders/ConfigurationBuilderSpecs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void ShouldHaveProxyConfiguration()
140140
if (!SystemSet && !ArgumentSet && !ConfigSet &&
141141
!EnvironmentVariableSet)
142142
{
143-
Configuration.Proxy.Location.Should().Be(string.Empty);
143+
Configuration.Proxy.Location.Should().BeEmpty();
144144
return;
145145
}
146146

@@ -211,7 +211,7 @@ public void ShouldBypassProxy()
211211
if (!ArgumentSet && !ConfigSet &&
212212
!EnvironmentVariableSet)
213213
{
214-
Configuration.Proxy.BypassList.Should().Be(string.Empty);
214+
Configuration.Proxy.BypassList.Should().BeEmpty();
215215
return;
216216
}
217217

src/chocolatey.tests.integration/infrastructure.app/services/FilesServiceSpecs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void Should_log_a_warning_about_locked_files()
101101
[Fact]
102102
public void Should_return_a_special_code_for_locked_files()
103103
{
104-
_result.Files.FirstOrDefault(x => x.Path == _theLockedFile).Checksum.Should().Be(ApplicationParameters.HashProviderFileLocked);
104+
_result.Files.Should().ContainSingle(x => x.Path == _theLockedFile).Which.Checksum.Should().Be(ApplicationParameters.HashProviderFileLocked);
105105
}
106106
}
107107
}

src/chocolatey.tests.integration/infrastructure/filesystem/DotNetFileSystemSpecs.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ public void GetExecutablePath_should_return_same_value_when_executable_is_not_fo
8585
[Fact]
8686
public void GetExecutablePath_should_return_empty_string_when_value_is_null()
8787
{
88-
FileSystem.GetExecutablePath(null).Should().Be(string.Empty);
88+
FileSystem.GetExecutablePath(null).Should().BeEmpty();
8989
}
9090

9191
[Fact]
9292
public void GetExecutablePath_should_return_empty_string_when_value_is_empty_string()
9393
{
94-
FileSystem.GetExecutablePath(string.Empty).Should().Be(string.Empty);
94+
FileSystem.GetExecutablePath(string.Empty).Should().BeEmpty();
9595
}
9696
}
9797

@@ -130,8 +130,8 @@ public void GetFiles_should_return_files_that_meet_the_pattern()
130130
var actual = FileSystem.GetFiles(ContextPath, "chocolateyInstall.ps1", SearchOption.AllDirectories).ToList();
131131
FileSystem.DeleteFile(filePath);
132132

133-
actual.Should().NotBeEmpty();
134-
actual.Count().Should().Be(1);
133+
actual.Should().NotBeEmpty()
134+
.And.HaveCount(1);
135135
}
136136

137137
[Fact]
@@ -145,8 +145,8 @@ public void GetFiles_should_return_files_that_meet_the_pattern_regardless_of_cas
145145
var actual = FileSystem.GetFiles(ContextPath, "chocolateyinstall.ps1", SearchOption.AllDirectories).ToList();
146146
FileSystem.DeleteFile(filePath);
147147

148-
actual.Should().NotBeEmpty();
149-
actual.Count().Should().Be(1);
148+
actual.Should().NotBeEmpty()
149+
.And.HaveCount(1);
150150
}
151151

152152
[Fact]
@@ -205,7 +205,7 @@ public override void Because()
205205
[Fact]
206206
public void Visible_file_should_now_be_hidden()
207207
{
208-
((FileAttributes)FileSystem.GetFileInfoFor(SourceFile).Attributes & FileAttributes.Hidden).Should().Be(FileAttributes.Hidden);
208+
((FileAttributes)FileSystem.GetFileInfoFor(SourceFile).Attributes).Should().HaveFlag(FileAttributes.Hidden);
209209
}
210210

211211
public override void AfterObservations()
@@ -232,7 +232,7 @@ public override void Because()
232232
[Fact]
233233
public void Readonly_file_should_no_longer_be_readonly()
234234
{
235-
((FileAttributes)FileSystem.GetFileInfoFor(SourceFile).Attributes & FileAttributes.ReadOnly).Should().NotBe(FileAttributes.ReadOnly);
235+
((FileAttributes)FileSystem.GetFileInfoFor(SourceFile).Attributes).Should().NotHaveFlag(FileAttributes.ReadOnly);
236236
}
237237
}
238238

src/chocolatey.tests.integration/scenarios/InfoScenarios.cs

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)