-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
240 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Cake.AzureDevOps.Tests/Fakes/FakeAllSetWorkItemTrackingClientFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Cake.AzureDevOps.Tests.Fakes | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using Cake.AzureDevOps.Authentication; | ||
using Microsoft.TeamFoundation.TestManagement.WebApi; | ||
using Microsoft.TeamFoundation.WorkItemTracking.WebApi; | ||
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; | ||
using Moq; | ||
|
||
public class FakeAllSetWorkItemTrackingClientFactory : FakeWorkItemTrackingClientFactory | ||
{ | ||
public override WorkItemTrackingHttpClient CreateWorkItemTrackingClient(Uri collectionUrl, IAzureDevOpsCredentials credentials) | ||
{ | ||
var mock = new Mock<WorkItemTrackingHttpClient>(MockBehavior.Strict, collectionUrl, credentials.ToVssCredentials()); | ||
|
||
mock.Setup(arg => arg.GetWorkItemsAsync(It.IsAny<IEnumerable<int>>(), It.IsAny<IEnumerable<string>>(), It.IsAny<DateTime?>(), It.IsAny<WorkItemExpand?>(), It.IsAny<WorkItemErrorPolicy?>(), null, default)) | ||
.ReturnsAsync((IEnumerable<int> workItemIds, IEnumerable<string> fields, DateTime? asOf, WorkItemExpand? expand, WorkItemErrorPolicy? errorPolicy, object userState, CancellationToken token) => | ||
{ | ||
var result = new List<WorkItem>(); | ||
|
||
foreach (var workItemId in workItemIds) | ||
{ | ||
result.Add(new WorkItem { Id = workItemId }); | ||
} | ||
|
||
return result; | ||
}); | ||
|
||
mock = this.Setup(mock); | ||
|
||
return mock.Object; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Cake.AzureDevOps.Tests/Fakes/FakeWorkItemTrackingClientFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Cake.AzureDevOps.Tests.Fakes | ||
{ | ||
using System; | ||
using Cake.AzureDevOps.Authentication; | ||
using Microsoft.TeamFoundation.WorkItemTracking.WebApi; | ||
using Microsoft.VisualStudio.Services.Identity; | ||
using Moq; | ||
|
||
public abstract class FakeWorkItemTrackingClientFactory : IWorkItemTrackingClientFactory | ||
{ | ||
public abstract WorkItemTrackingHttpClient CreateWorkItemTrackingClient(Uri collectionUrl, IAzureDevOpsCredentials credentials); | ||
|
||
public WorkItemTrackingHttpClient CreateWorkItemTrackingClient(Uri collectionUrl, IAzureDevOpsCredentials credentials, out Identity authorizedIdentity) | ||
{ | ||
authorizedIdentity = new Identity { ProviderDisplayName = "FakeUser", Id = Guid.NewGuid(), IsActive = true }; | ||
return this.CreateWorkItemTrackingClient(collectionUrl, credentials); | ||
} | ||
|
||
protected virtual Mock<WorkItemTrackingHttpClient> Setup(Mock<WorkItemTrackingHttpClient> m) | ||
{ | ||
return m; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.