Skip to content

Commit 5460cf7

Browse files
edvilmekasperk81
andauthored
Apply suggestions from code review
Co-authored-by: kasperk81 <[email protected]>
1 parent 62f9277 commit 5460cf7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/dotnet-sln.Tests/GivenDotnetSlnRemove.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public async Task WhenPassedAReferenceItRemovesTheReferenceButNotOtherReferences
230230

231231
var solutionPath = Path.Combine(projectDirectory, $"App{solutionExtension}");
232232

233-
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath);
233+
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath) ?? throw new InvalidOperationException($"Unable to get solution serializer for {solutionPath}.");
234234
SolutionModel solution = await serializer.OpenAsync(solutionPath, CancellationToken.None);
235235

236236
solution.SolutionProjects.Count.Should().Be(2);
@@ -285,7 +285,7 @@ public async Task WhenDuplicateReferencesArePresentItRemovesThemAll(string solut
285285
.Path;
286286

287287
var solutionPath = Path.Combine(projectDirectory, "App.sln");
288-
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath);
288+
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath) ?? throw new InvalidOperationException($"Unable to get solution serializer for {solutionPath}.");
289289
SolutionModel solution = await serializer.OpenAsync(solutionPath, CancellationToken.None);
290290
solution.SolutionProjects.Count.Should().Be(3);
291291

@@ -318,7 +318,7 @@ public async Task WhenPassedMultipleReferencesAndOneOfThemDoesNotExistItRemovesT
318318

319319
var solutionPath = Path.Combine(projectDirectory, $"App{solutionExtension}");
320320

321-
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath);
321+
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath) ?? throw new InvalidOperationException($"Unable to get solution serializer for {solutionPath}.");
322322
SolutionModel solution = await serializer.OpenAsync(solutionPath, CancellationToken.None);
323323

324324
solution.SolutionProjects.Count.Should().Be(2);
@@ -354,7 +354,7 @@ public async Task WhenReferenceIsRemovedBuildConfigsAreAlsoRemoved(string soluti
354354

355355
var solutionPath = Path.Combine(projectDirectory, $"App{solutionExtension}");
356356

357-
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath);
357+
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath) ?? throw new InvalidOperationException($"Unable to get solution serializer for {solutionPath}.");
358358
SolutionModel solution = await serializer.OpenAsync(solutionPath, CancellationToken.None);
359359

360360
solution.SolutionProjects.Count.Should().Be(2);
@@ -384,7 +384,7 @@ public async Task WhenDirectoryContainingProjectIsGivenProjectIsRemoved(string s
384384

385385
var solutionPath = Path.Combine(projectDirectory, $"App{solutionExtension}");
386386

387-
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath);
387+
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath) ?? throw new InvalidOperationException($"Unable to get solution serializer for {solutionPath}.");
388388
SolutionModel solution = await serializer.OpenAsync(solutionPath, CancellationToken.None);
389389

390390
solution.SolutionProjects.Count.Should().Be(2);
@@ -461,7 +461,7 @@ public async Task WhenReferenceIsRemovedSlnBuilds(string solutionCommand, string
461461

462462
var solutionPath = Path.Combine(projectDirectory, $"App{solutionExtension}");
463463

464-
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath);
464+
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath) ?? throw new InvalidOperationException($"Unable to get solution serializer for {solutionPath}.");
465465
SolutionModel solution = await serializer.OpenAsync(solutionPath, CancellationToken.None);
466466

467467
solution.SolutionProjects.Count.Should().Be(2);
@@ -535,7 +535,7 @@ public async Task WhenFinalReferenceIsRemovedEmptySectionsAreRemoved(string solu
535535

536536
var solutionPath = Path.Combine(projectDirectory, $"App{solutionExtension}");
537537

538-
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath);
538+
ISolutionSerializer serializer = SolutionSerializers.GetSerializerByMoniker(solutionPath) ?? throw new InvalidOperationException($"Unable to get solution serializer for {solutionPath}.");
539539
SolutionModel solution = await serializer.OpenAsync(solutionPath, CancellationToken.None);
540540
solution.SolutionProjects.Count.Should().Be(2);
541541

0 commit comments

Comments
 (0)