Skip to content

Commit 741b91f

Browse files
committed
Fix test analyzer warnings
1 parent 95c2e06 commit 741b91f

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

LibGit2Sharp.Tests/BranchFixture.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using Xunit.Extensions;
87

98
namespace LibGit2Sharp.Tests
109
{
@@ -103,7 +102,7 @@ public void CanCreateAnUnbornBranch()
103102
public void CanCreateBranchUsingAbbreviatedSha()
104103
{
105104
string path = SandboxBareTestRepo();
106-
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
105+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
107106
{
108107
EnableRefLog(repo);
109108

@@ -1001,7 +1000,7 @@ public void OnlyOneBranchIsTheHead()
10011000
continue;
10021001
}
10031002

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

10071006
Assert.NotNull(head);

LibGit2Sharp.Tests/FilterFixture.cs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using System.IO;
4+
using System.Threading.Tasks;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using System.Threading.Tasks;
87

98
namespace LibGit2Sharp.Tests
109
{
@@ -174,7 +173,7 @@ public void CleanFilterWritesOutputToObjectTree()
174173
}
175174

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

194193
for (int i = 0; i < count; i++)
195194
{
196-
tasks[i] = Task.Factory.StartNew(() =>
195+
tasks[i] = Task.Run(() =>
197196
{
198197
string repoPath = InitNewRepository();
199198
return CheckoutFileForSmudge(repoPath, branchName, encodedInput);
200199
});
201200
}
202201

203-
Task.WaitAll(tasks);
202+
var files = await Task.WhenAll(tasks);
204203

205-
foreach(var task in tasks)
204+
foreach (var file in files)
206205
{
207-
FileInfo expectedFile = task.Result;
208-
209-
string readAllText = File.ReadAllText(expectedFile.FullName);
206+
string readAllText = File.ReadAllText(file.FullName);
210207
Assert.Equal(decodedInput, readAllText);
211208
}
212209
}

LibGit2Sharp.Tests/MetaFixture.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void TypesInLibGit2DecoratedWithDebuggerDisplayMustFollowTheStandardImplP
112112

113113
if (typesWithDebuggerDisplayAndInvalidImplPattern.Any())
114114
{
115-
Assert.True(false, Environment.NewLine + BuildMissingDebuggerDisplayPropertyMessage(typesWithDebuggerDisplayAndInvalidImplPattern));
115+
Assert.Fail(Environment.NewLine + BuildMissingDebuggerDisplayPropertyMessage(typesWithDebuggerDisplayAndInvalidImplPattern));
116116
}
117117
}
118118

@@ -167,7 +167,7 @@ public void TypesInLibGit2SharpMustBeExtensibleInATestingContext()
167167

168168
if (nonTestableTypes.Any())
169169
{
170-
Assert.True(false, Environment.NewLine + BuildNonTestableTypesMessage(nonTestableTypes));
170+
Assert.Fail(Environment.NewLine + BuildNonTestableTypesMessage(nonTestableTypes));
171171
}
172172
}
173173

@@ -287,7 +287,7 @@ public void GetEnumeratorMethodsInLibGit2SharpMustBeVirtualForTestability()
287287
method.DeclaringType, Environment.NewLine);
288288
}
289289

290-
Assert.True(false, Environment.NewLine + sb.ToString());
290+
Assert.Fail(Environment.NewLine + sb.ToString());
291291
}
292292
}
293293

@@ -316,7 +316,7 @@ public void NoPublicTypesUnderLibGit2SharpCoreNamespace()
316316
type.FullName, coreNamespace, Environment.NewLine);
317317
}
318318

319-
Assert.True(false, Environment.NewLine + sb.ToString());
319+
Assert.Fail(Environment.NewLine + sb.ToString());
320320
}
321321
}
322322

LibGit2Sharp.Tests/PushFixture.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public class PushFixture : BaseFixture
1212
{
1313
private void OnPushStatusError(PushStatusError pushStatusErrors)
1414
{
15-
Assert.True(false, string.Format("Failed to update reference '{0}': {1}",
16-
pushStatusErrors.Reference, pushStatusErrors.Message));
15+
Assert.Fail(string.Format("Failed to update reference '{0}': {1}", pushStatusErrors.Reference, pushStatusErrors.Message));
1716
}
1817

1918
private void AssertPush(Action<IRepository> push)

0 commit comments

Comments
 (0)