Skip to content

Commit 08ef159

Browse files
committed
Merge branch 'release/0.2.7'
2 parents a439220 + 08b38d2 commit 08ef159

File tree

7 files changed

+76
-11
lines changed

7 files changed

+76
-11
lines changed

nuspec/nuget/Cake.Tfs.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<repository type="git" url="https://github.com/cake-contrib/Cake.Tfs"/>
1818
<copyright>Copyright © Pascal Berger</copyright>
1919
<tags>Cake Script Team-Foundation-Server TFS Azure-DevOps</tags>
20-
<releaseNotes>https://github.com/cake-contrib/Cake.Tfs/releases/tag/0.2.6</releaseNotes>
20+
<releaseNotes>https://github.com/cake-contrib/Cake.Tfs/releases/tag/0.2.7</releaseNotes>
2121
</metadata>
2222
<files>
2323
<file src="net461\Cake.Tfs.dll" target="lib\net461" />

src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
1818
<PackageReference Include="Cake.Core" Version="0.28.0" />
1919
<PackageReference Include="Cake.Testing" Version="0.28.0" />
2020
<PackageReference Include="Moq" Version="4.10.1" />

src/Cake.Tfs.Tests/PullRequest/CommentThread/TfsPullRequestCommentThreadTests.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,67 @@ public void Should_Throw_If_Property_Name_Is_Empty()
259259
}
260260

261261
[Fact]
262-
public void Should_Throw_If_Property_Collection_Is_Null()
262+
public void Should_Return_Default_Value_If_Property_Collection_Is_Null_For_String_Value()
263263
{
264264
// Given
265265
var tfsThread = new TfsPullRequestCommentThread();
266266

267267
// When
268-
var result = Record.Exception(() => tfsThread.GetValue<int>("key"));
268+
var result = tfsThread.GetValue<string>("key");
269269

270270
// Then
271-
result.IsInvalidOperationException();
271+
result.ShouldBe(default(string));
272+
}
273+
274+
[Fact]
275+
public void Should_Return_Default_Value_If_Property_Collection_Is_Null_For_Integer_Value()
276+
{
277+
// Given
278+
var tfsThread = new TfsPullRequestCommentThread();
279+
280+
// When
281+
var result = tfsThread.GetValue<int>("key");
282+
283+
// Then
284+
result.ShouldBe(default(int));
285+
}
286+
287+
[Fact]
288+
public void Should_Return_Default_Value_If_Property_Does_Not_Exist_For_String_Value()
289+
{
290+
// Given
291+
var tfsThread = new TfsPullRequestCommentThread(
292+
new GitPullRequestCommentThread
293+
{
294+
Id = 42,
295+
Status = CommentThreadStatus.Active,
296+
Properties = new PropertiesCollection()
297+
});
298+
299+
// When
300+
var result = tfsThread.GetValue<string>("key");
301+
302+
// Then
303+
result.ShouldBe(default(string));
304+
}
305+
306+
[Fact]
307+
public void Should_Return_Default_Value_If_Property_Does_Not_Exist_For_Int_Value()
308+
{
309+
// Given
310+
var tfsThread = new TfsPullRequestCommentThread(
311+
new GitPullRequestCommentThread
312+
{
313+
Id = 42,
314+
Status = CommentThreadStatus.Active,
315+
Properties = new PropertiesCollection()
316+
});
317+
318+
// When
319+
var result = tfsThread.GetValue<int>("key");
320+
321+
// Then
322+
result.ShouldBe(default(int));
272323
}
273324

274325
[Fact]

src/Cake.Tfs/Cake.Tfs.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
<ItemGroup>
2525
<PackageReference Include="Cake.Core" Version="0.28.0" />
26-
<PackageReference Include="Costura.Fody" Version="3.3.2" />
27-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.6.3" />
26+
<PackageReference Include="Costura.Fody" Version="3.3.3" />
27+
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.1" />
2828
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="15.131.1" />
2929
<PackageReference Include="Microsoft.VisualStudio.Services.InteractiveClient" Version="15.131.1" />
3030
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" />

src/Cake.Tfs/PullRequest/CommentThread/TfsPullRequestCommentThread.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ public IDictionary<string, object> Properties
119119
/// </summary>
120120
/// <typeparam name="T">Type of the value.</typeparam>
121121
/// <param name="propertyName">Name of the property.</param>
122-
/// <returns>Value of the property.</returns>
122+
/// <returns>Value of the property or default value for <typeparamref name="T"/> if property does not exist.</returns>
123123
public T GetValue<T>(string propertyName)
124124
{
125125
propertyName.NotNullOrWhiteSpace(nameof(propertyName));
126126

127127
if (this.thread.Properties == null)
128128
{
129-
throw new InvalidOperationException("Properties collection is not created.");
129+
return default(T);
130130
}
131131

132132
return this.thread.Properties.GetValue(propertyName, default(T));
@@ -138,6 +138,7 @@ public T GetValue<T>(string propertyName)
138138
/// <typeparam name="T">Type of the value.</typeparam>
139139
/// <param name="propertyName">Name of the property.</param>
140140
/// <param name="value">Value to set.</param>
141+
/// <exception cref="InvalidOperationException">If properties collection is not created.</exception>
141142
public void SetValue<T>(string propertyName, T value)
142143
{
143144
propertyName.NotNullOrWhiteSpace(nameof(propertyName));

src/Cake.Tfs/TfsAliases.Authentication.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
/// <content>
88
/// Contains functionality related to authenticating to Team Foundation Server or Azure DevOps.
99
/// </content>
10-
[CakeNamespaceImport("Cake.Tfs.Authentication")]
1110
public static partial class TfsAliases
1211
{
1312
/// <summary>
@@ -18,6 +17,7 @@ public static partial class TfsAliases
1817
/// <returns>Credentials for integrated / NTLM authentication</returns>
1918
[CakeMethodAlias]
2019
[CakeAliasCategory("Authentication")]
20+
[CakeNamespaceImport("Cake.Tfs.Authentication")]
2121
public static ITfsCredentials TfsAuthenticationNtlm(
2222
this ICakeContext context)
2323
{
@@ -37,6 +37,7 @@ public static ITfsCredentials TfsAuthenticationNtlm(
3737
/// <returns>Credentials for basic authentication.</returns>
3838
[CakeMethodAlias]
3939
[CakeAliasCategory("Authentication")]
40+
[CakeNamespaceImport("Cake.Tfs.Authentication")]
4041
public static ITfsCredentials TfsAuthenticationBasic(
4142
this ICakeContext context,
4243
string userName,
@@ -58,6 +59,7 @@ public static ITfsCredentials TfsAuthenticationBasic(
5859
/// <returns>Credentials for authentication with a personal access token.</returns>
5960
[CakeMethodAlias]
6061
[CakeAliasCategory("Authentication")]
62+
[CakeNamespaceImport("Cake.Tfs.Authentication")]
6163
public static ITfsCredentials TfsAuthenticationPersonalAccessToken(
6264
this ICakeContext context,
6365
string personalAccessToken)
@@ -77,6 +79,7 @@ public static ITfsCredentials TfsAuthenticationPersonalAccessToken(
7779
/// <returns>Credentials for OAuth authentication.</returns>
7880
[CakeMethodAlias]
7981
[CakeAliasCategory("Authentication")]
82+
[CakeNamespaceImport("Cake.Tfs.Authentication")]
8083
public static ITfsCredentials TfsAuthenticationOAuth(
8184
this ICakeContext context,
8285
string accessToken)
@@ -97,6 +100,7 @@ public static ITfsCredentials TfsAuthenticationOAuth(
97100
/// <returns>Credentials for authentication with an Azure Active Directory.</returns>
98101
[CakeMethodAlias]
99102
[CakeAliasCategory("Authentication")]
103+
[CakeNamespaceImport("Cake.Tfs.Authentication")]
100104
public static ITfsCredentials TfsAuthenticationAzureActiveDirectory(
101105
this ICakeContext context,
102106
string userName,

src/Cake.Tfs/TfsAliases.PullRequest.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
/// <content>
99
/// Contains functionality related to Team Foundation Server or Azure DevOps pull requests.
1010
/// </content>
11-
[CakeNamespaceImport("Cake.Tfs.PullRequest")]
1211
public static partial class TfsAliases
1312
{
1413
/// <summary>
@@ -39,6 +38,8 @@ public static partial class TfsAliases
3938
/// <see cref="TfsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
4039
[CakeMethodAlias]
4140
[CakeAliasCategory("Pull Request")]
41+
[CakeNamespaceImport("Cake.Tfs.PullRequest")]
42+
[CakeNamespaceImport("Cake.Tfs.PullRequest.CommentThread")]
4243
public static TfsPullRequest TfsPullRequest(
4344
this ICakeContext context,
4445
TfsPullRequestSettings settings)
@@ -80,6 +81,8 @@ public static TfsPullRequest TfsPullRequest(
8081
/// 'Allow Scripts to access OAuth token' option is not enabled on the build definition.</exception>
8182
[CakeMethodAlias]
8283
[CakeAliasCategory("Pull Request")]
84+
[CakeNamespaceImport("Cake.Tfs.PullRequest")]
85+
[CakeNamespaceImport("Cake.Tfs.PullRequest.CommentThread")]
8386
public static TfsPullRequest TfsPullRequestUsingTfsBuildOAuthToken(
8487
this ICakeContext context)
8588
{
@@ -117,6 +120,8 @@ public static TfsPullRequest TfsPullRequestUsingTfsBuildOAuthToken(
117120
/// <see cref="TfsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
118121
[CakeMethodAlias]
119122
[CakeAliasCategory("Pull Request")]
123+
[CakeNamespaceImport("Cake.Tfs.PullRequest")]
124+
[CakeNamespaceImport("Cake.Tfs.PullRequest.CommentThread")]
120125
public static void TfsVotePullRequest(
121126
this ICakeContext context,
122127
TfsPullRequestSettings settings,
@@ -163,6 +168,8 @@ public static void TfsVotePullRequest(
163168
/// <see cref="TfsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/> is set to <c>true</c>.</exception>
164169
[CakeMethodAlias]
165170
[CakeAliasCategory("Pull Request")]
171+
[CakeNamespaceImport("Cake.Tfs.PullRequest")]
172+
[CakeNamespaceImport("Cake.Tfs.PullRequest.CommentThread")]
166173
public static void TfsSetPullRequestStatus(
167174
this ICakeContext context,
168175
TfsPullRequestSettings settings,
@@ -203,6 +210,8 @@ public static void TfsSetPullRequestStatus(
203210
/// <exception cref="TfsBranchNotFoundException">If the target branch could not be found.</exception>
204211
[CakeMethodAlias]
205212
[CakeAliasCategory("Pull Request")]
213+
[CakeNamespaceImport("Cake.Tfs.PullRequest")]
214+
[CakeNamespaceImport("Cake.Tfs.PullRequest.CommentThread")]
206215
public static TfsPullRequest TfsCreatePullRequest(
207216
this ICakeContext context,
208217
TfsCreatePullRequestSettings settings)

0 commit comments

Comments
 (0)