Skip to content

Commit ef38481

Browse files
authored
Fix warnings (#350)
1 parent 0580271 commit ef38481

13 files changed

+45
-43
lines changed

src/Cake.AzureDevOps.Tests/ExceptionAssertExtensions.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ public static void IsArgumentException<T>(this T exception, Type expectedExcepti
2323
Assert.Equal(parameterName, exception.ParamName);
2424
}
2525

26+
/// <summary>
27+
/// Checks if an exception is of type <see cref="ArgumentException"/>.
28+
/// </summary>
29+
/// <param name="exception">Exception to check.</param>
30+
/// <param name="parameterName">Expected name of the parameter which has caused the exception.</param>
31+
public static void IsArgumentException(this Exception exception, string parameterName)
32+
{
33+
Assert.IsType<ArgumentException>(exception);
34+
Assert.Equal(parameterName, ((ArgumentException)exception).ParamName);
35+
}
36+
2637
/// <summary>
2738
/// Checks if an exception is of type <see cref="ArgumentNullException"/>.
2839
/// </summary>
@@ -45,17 +56,6 @@ public static void IsArgumentOutOfRangeException(this Exception exception, strin
4556
Assert.Equal(parameterName, ((ArgumentOutOfRangeException)exception).ParamName);
4657
}
4758

48-
/// <summary>
49-
/// Checks if an exception is of type <see cref="ArgumentException"/>.
50-
/// </summary>
51-
/// <param name="exception">Exception to check.</param>
52-
/// <param name="parameterName">Expected name of the parameter which has caused the exception.</param>
53-
public static void IsArgumentException(this Exception exception, string parameterName)
54-
{
55-
Assert.IsType<ArgumentException>(exception);
56-
Assert.Equal(parameterName, ((ArgumentException)exception).ParamName);
57-
}
58-
5959
/// <summary>
6060
/// Checks if an exception is of type <see cref="InvalidOperationException"/>.
6161
/// </summary>

src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetBuildClientFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public override BuildHttpClient CreateBuildClient(Uri collectionUrl, IAzureDevOp
1313
{
1414
var mock = new Mock<BuildHttpClient>(MockBehavior.Loose, collectionUrl, credentials.ToVssCredentials());
1515

16-
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, null, default(CancellationToken)))
16+
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, null, default))
1717
.ReturnsAsync((Guid projectId, int buildId, string propertyFilters, object userState, CancellationToken token) => new Build
1818
{
1919
Id = buildId,
2020
BuildNumber = buildId.ToString(),
2121
Project = new TeamProjectReference { Id = projectId },
2222
});
2323

24-
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<string>(), It.IsAny<int>(), null, null, default(CancellationToken)))
24+
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<string>(), It.IsAny<int>(), null, null, default))
2525
.ReturnsAsync((string projectName, int buildId, string propertyFilters, object userState, CancellationToken token) => new Build
2626
{
2727
Id = buildId,

src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetGitClientFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public override GitHttpClient CreateGitClient(Uri collectionUrl, IAzureDevOpsCre
1414
{
1515
var mock = new Mock<GitHttpClient>(MockBehavior.Loose, collectionUrl, credentials.ToVssCredentials());
1616

17-
mock.Setup(arg => arg.GetPullRequestAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), null, null, null, null, null, null, default(CancellationToken)))
17+
mock.Setup(arg => arg.GetPullRequestAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), null, null, null, null, null, null, default))
1818
.ReturnsAsync((string project1, string repoId1, int prId, int i1, int i2, int i3, bool b1, bool b2, object o1, CancellationToken c1) => new GitPullRequest
1919
{
2020
PullRequestId = prId,
@@ -39,7 +39,7 @@ public override GitHttpClient CreateGitClient(Uri collectionUrl, IAzureDevOpsCre
3939
null,
4040
1,
4141
null,
42-
default(CancellationToken)))
42+
default))
4343
.ReturnsAsync((string project2, string repoId2, GitPullRequestSearchCriteria sc, int j1, int j2, int top, object o2, CancellationToken c2)
4444
=> new List<GitPullRequest>(new[]
4545
{
@@ -73,7 +73,7 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
7373
It.IsAny<int>(),
7474
It.IsAny<string>(),
7575
It.IsAny<object>(),
76-
default(CancellationToken)))
76+
default))
7777
.ReturnsAsync((IdentityRefWithVote identity, Guid project, int prId, string reviewerId, object o, CancellationToken c)
7878
=> new IdentityRefWithVote
7979
{
@@ -86,7 +86,7 @@ protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
8686
It.IsAny<int>(),
8787
It.IsAny<string>(),
8888
It.IsAny<object>(),
89-
default(CancellationToken)))
89+
default))
9090
.Throws(new Exception("Something went wrong"));
9191

9292
m.Setup(arg => arg.CreatePullRequestStatusAsync(

src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetTestManagementClientFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public override TestManagementHttpClient CreateTestManagementClient(Uri collecti
1414
{
1515
var mock = new Mock<TestManagementHttpClient>(MockBehavior.Strict, collectionUrl, credentials.ToVssCredentials());
1616

17-
mock.Setup(arg => arg.GetTestResultDetailsForBuildAsync(It.IsAny<Guid>(), It.Is<int>(id => id == 1), null, null, null, null, null, null, null, default(CancellationToken)))
17+
mock.Setup(arg => arg.GetTestResultDetailsForBuildAsync(It.IsAny<Guid>(), It.Is<int>(id => id == 1), null, null, null, null, null, null, null, default))
1818
.ReturnsAsync(() => new TestResultsDetails { ResultsForGroup = new List<TestResultsDetailsForGroup>() });
1919

20-
mock.Setup(arg => arg.GetTestResultDetailsForBuildAsync(It.IsAny<Guid>(), It.Is<int>(id => id > 1), null, null, null, null, null, null, null, default(CancellationToken)))
20+
mock.Setup(arg => arg.GetTestResultDetailsForBuildAsync(It.IsAny<Guid>(), It.Is<int>(id => id > 1), null, null, null, null, null, null, null, default))
2121
.ReturnsAsync(() => new TestResultsDetails
2222
{
2323
ResultsForGroup = new List<TestResultsDetailsForGroup>()
@@ -34,7 +34,7 @@ public override TestManagementHttpClient CreateTestManagementClient(Uri collecti
3434
},
3535
});
3636

37-
mock.Setup(arg => arg.GetTestResultsAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, It.IsAny<int?>(), It.IsAny<int?>(), It.IsAny<IEnumerable<TestOutcome>>(), null, default(CancellationToken)))
37+
mock.Setup(arg => arg.GetTestResultsAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, It.IsAny<int?>(), It.IsAny<int?>(), It.IsAny<IEnumerable<TestOutcome>>(), null, default))
3838
.ReturnsAsync((Guid projectId, int testRunId, ResultDetails? details, int? skip, int? top, IEnumerable<TestOutcome> outcomes, object userState, CancellationToken token) => new List<TestCaseResult>()
3939
{
4040
new TestCaseResult { AutomatedTestName = "t1", Outcome = "Passed", ErrorMessage = string.Empty },

src/Cake.AzureDevOps.Tests/Fakes/FakeNullBuildClientFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public override BuildHttpClient CreateBuildClient(Uri collectionUrl, IAzureDevOp
1212
{
1313
var mock = new Mock<BuildHttpClient>(MockBehavior.Loose, collectionUrl, credentials.ToVssCredentials());
1414

15-
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, null, default(CancellationToken)))
15+
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<Guid>(), It.IsAny<int>(), null, null, default))
1616
.ReturnsAsync(() => null);
1717

18-
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<string>(), It.IsAny<int>(), null, null, default(CancellationToken)))
18+
mock.Setup(arg => arg.GetBuildAsync(It.IsAny<string>(), It.IsAny<int>(), null, null, default))
1919
.ReturnsAsync(() => null);
2020

2121
mock = this.Setup(mock);

src/Cake.AzureDevOps.Tests/Fakes/FakeNullForMethodsGitClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class FakeNullForMethodsGitClientFactory : FakeAllSetGitClientFactory
1010
{
1111
protected override Mock<GitHttpClient> Setup(Mock<GitHttpClient> m)
1212
{
13-
m.Setup(arg => arg.CreatePullRequestReviewerAsync(It.IsAny<IdentityRefWithVote>(), It.IsAny<Guid>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<object>(), default(CancellationToken)))
13+
m.Setup(arg => arg.CreatePullRequestReviewerAsync(It.IsAny<IdentityRefWithVote>(), It.IsAny<Guid>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<object>(), default))
1414
.ReturnsAsync(() => null);
1515

1616
m.Setup(arg => arg.CreatePullRequestStatusAsync(It.IsAny<GitPullRequestStatus>(), It.IsAny<Guid>(), It.IsAny<int>(), It.IsAny<object>(), It.IsAny<CancellationToken>()))

src/Cake.AzureDevOps.Tests/Fakes/FakeNullGitClientFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public override GitHttpClient CreateGitClient(Uri collectionUrl, IAzureDevOpsCre
1313
{
1414
var mock = new Mock<GitHttpClient>(MockBehavior.Loose, collectionUrl, credentials.ToVssCredentials());
1515

16-
mock.Setup(arg => arg.GetPullRequestAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), null, null, null, null, null, null, default(CancellationToken)))
16+
mock.Setup(arg => arg.GetPullRequestAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), null, null, null, null, null, null, default))
1717
.ReturnsAsync(() => null);
1818

19-
mock.Setup(arg => arg.GetPullRequestsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GitPullRequestSearchCriteria>(), null, null, 1, null, default(CancellationToken)))
19+
mock.Setup(arg => arg.GetPullRequestsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GitPullRequestSearchCriteria>(), null, null, 1, null, default))
2020
.ReturnsAsync(() => new List<GitPullRequest>());
2121

2222
mock = this.Setup(mock);

src/Cake.AzureDevOps.Tests/Pipelines/AzureDevOpsBuildSettingsTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,6 @@ public void Should_Throw_If_System_Access_Token_Env_Var_Is_Empty_And_Correct_Bui
991991
public void Should_Throw_If_Build_Id_Env_Var_Is_Set_But_Ctor_Build_Id_Value_Zero_With_OAuthToken()
992992
{
993993
// Given
994-
var creds = new AzureDevOpsNtlmCredentials();
995994
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
996995
Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
997996
Environment.SetEnvironmentVariable("BUILD_BUILDID", "20");
@@ -1008,7 +1007,6 @@ public void Should_Throw_If_Build_Id_Env_Var_Is_Set_But_Ctor_Build_Id_Value_Zero
10081007
public void Should_Throw_If_Build_Id_Env_Var_Is_Set_But_Ctor_Build_Id_Value_Negative_With_OAuthToken()
10091008
{
10101009
// Given
1011-
var creds = new AzureDevOpsNtlmCredentials();
10121010
Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
10131011
Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
10141012
Environment.SetEnvironmentVariable("BUILD_BUILDID", "20");

src/Cake.AzureDevOps.Tests/Pipelines/AzureDevOpsBuildsSettingsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Shouldly;
77
using Xunit;
88

9-
public sealed class BaseAzureDevOpsCredentialsSettingsTests
9+
public sealed class AzureDevOpsBuildsSettingsTests
1010
{
1111
public sealed class TheCtorForProjectGuid
1212
{

src/Cake.AzureDevOps.Tests/Repos/PullRequest/AzureDevOpsPullRequestTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,10 @@ public void Should_Delete_Comment_By_Comment_Properties()
10181018
// Given
10191019
var fixture = new PullRequestFixture(BasePullRequestFixture.ValidAzureDevOpsServerUrl, 100);
10201020
var pullRequest = new AzureDevOpsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory);
1021-
var inComment = new AzureDevOpsComment(new Microsoft.TeamFoundation.SourceControl.WebApi.Comment { Id = 1 }, 5);
1022-
inComment.Content = "new Content";
1021+
var inComment = new AzureDevOpsComment(new Microsoft.TeamFoundation.SourceControl.WebApi.Comment { Id = 1 }, 5)
1022+
{
1023+
Content = "new Content",
1024+
};
10231025

10241026
// When
10251027
pullRequest.DeleteComment(inComment);
@@ -1089,8 +1091,10 @@ public void Should_Return_Updated_Comment()
10891091
// Given
10901092
var fixture = new PullRequestFixture(BasePullRequestFixture.ValidAzureDevOpsUrl, 200);
10911093
var pullRequest = new AzureDevOpsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory);
1092-
var inComment = new AzureDevOpsComment(new Microsoft.TeamFoundation.SourceControl.WebApi.Comment { Id = 1 }, 5);
1093-
inComment.Content = "new Content";
1094+
var inComment = new AzureDevOpsComment(new Microsoft.TeamFoundation.SourceControl.WebApi.Comment { Id = 1 }, 5)
1095+
{
1096+
Content = "new Content",
1097+
};
10941098

10951099
// When
10961100
var outComment = pullRequest.UpdateComment(inComment);

0 commit comments

Comments
 (0)