Skip to content

Commit

Permalink
Fix test analyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Mar 16, 2024
1 parent 95c2e06 commit 741b91f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
5 changes: 2 additions & 3 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -103,7 +102,7 @@ public void CanCreateAnUnbornBranch()
public void CanCreateBranchUsingAbbreviatedSha()
{
string path = SandboxBareTestRepo();
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);

Expand Down Expand Up @@ -1001,7 +1000,7 @@ public void OnlyOneBranchIsTheHead()
continue;
}

Assert.True(false, string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
Assert.Fail(string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
}

Assert.NotNull(head);
Expand Down
15 changes: 6 additions & 9 deletions LibGit2Sharp.Tests/FilterFixture.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using System.Threading.Tasks;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -174,7 +173,7 @@ public void CleanFilterWritesOutputToObjectTree()
}

[Fact]
public void CanHandleMultipleSmudgesConcurrently()
public async Task CanHandleMultipleSmudgesConcurrently()
{
const string decodedInput = "This is a substitution cipher";
const string encodedInput = "Guvf vf n fhofgvghgvba pvcure";
Expand All @@ -193,20 +192,18 @@ public void CanHandleMultipleSmudgesConcurrently()

for (int i = 0; i < count; i++)
{
tasks[i] = Task.Factory.StartNew(() =>
tasks[i] = Task.Run(() =>
{
string repoPath = InitNewRepository();
return CheckoutFileForSmudge(repoPath, branchName, encodedInput);
});
}

Task.WaitAll(tasks);
var files = await Task.WhenAll(tasks);

foreach(var task in tasks)
foreach (var file in files)
{
FileInfo expectedFile = task.Result;

string readAllText = File.ReadAllText(expectedFile.FullName);
string readAllText = File.ReadAllText(file.FullName);
Assert.Equal(decodedInput, readAllText);
}
}
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/MetaFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void TypesInLibGit2DecoratedWithDebuggerDisplayMustFollowTheStandardImplP

if (typesWithDebuggerDisplayAndInvalidImplPattern.Any())
{
Assert.True(false, Environment.NewLine + BuildMissingDebuggerDisplayPropertyMessage(typesWithDebuggerDisplayAndInvalidImplPattern));
Assert.Fail(Environment.NewLine + BuildMissingDebuggerDisplayPropertyMessage(typesWithDebuggerDisplayAndInvalidImplPattern));
}
}

Expand Down Expand Up @@ -167,7 +167,7 @@ public void TypesInLibGit2SharpMustBeExtensibleInATestingContext()

if (nonTestableTypes.Any())
{
Assert.True(false, Environment.NewLine + BuildNonTestableTypesMessage(nonTestableTypes));
Assert.Fail(Environment.NewLine + BuildNonTestableTypesMessage(nonTestableTypes));
}
}

Expand Down Expand Up @@ -287,7 +287,7 @@ public void GetEnumeratorMethodsInLibGit2SharpMustBeVirtualForTestability()
method.DeclaringType, Environment.NewLine);
}

Assert.True(false, Environment.NewLine + sb.ToString());
Assert.Fail(Environment.NewLine + sb.ToString());
}
}

Expand Down Expand Up @@ -316,7 +316,7 @@ public void NoPublicTypesUnderLibGit2SharpCoreNamespace()
type.FullName, coreNamespace, Environment.NewLine);
}

Assert.True(false, Environment.NewLine + sb.ToString());
Assert.Fail(Environment.NewLine + sb.ToString());
}
}

Expand Down
3 changes: 1 addition & 2 deletions LibGit2Sharp.Tests/PushFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public class PushFixture : BaseFixture
{
private void OnPushStatusError(PushStatusError pushStatusErrors)
{
Assert.True(false, string.Format("Failed to update reference '{0}': {1}",
pushStatusErrors.Reference, pushStatusErrors.Message));
Assert.Fail(string.Format("Failed to update reference '{0}': {1}", pushStatusErrors.Reference, pushStatusErrors.Message));
}

private void AssertPush(Action<IRepository> push)
Expand Down

0 comments on commit 741b91f

Please sign in to comment.