Skip to content

Commit e2039c8

Browse files
authored
Injecting credential vault into Developer ID Provider (#202)
* Injecting credential vault into developeridprovider * Spacing * Fixing tests
1 parent dab50a1 commit e2039c8

File tree

8 files changed

+470
-462
lines changed

8 files changed

+470
-462
lines changed

Diff for: GitHubExtension.Test/Controls/SignInFormTest.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public async Task HandleOAuthRedirection_ShouldThrowInvalidOperationException_On
2727
return new OauthToken();
2828
});
2929

30-
var developerIdProvider = new DeveloperIdProvider();
30+
var mockCredentialVault = new Mock<ICredentialVault>();
31+
var developerIdProvider = new DeveloperIdProvider(mockCredentialVault.Object);
3132

3233
mockGitHubClient.Setup(client => client.Oauth).Returns(mockOauthClient.Object);
3334

Diff for: GitHubExtension.Test/DataStoreTests/DataManagerTests.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
using GitHubExtension.DataManager.Cache;
77
using GitHubExtension.DataManager.Data;
88
using GitHubExtension.DeveloperId;
9+
using Moq;
910

1011
namespace GitHubExtension.Test.DataStoreTests;
1112

1213
public partial class DataStoreTests
1314
{
14-
private DeveloperIdProvider GetDeveloperIdProvider() => new();
15+
private DeveloperIdProvider GetDeveloperIdProvider() => new(new Mock<ICredentialVault>().Object);
1516

1617
private GitHubClientProvider GetGitHubClientProvider(DeveloperIdProvider developerIdProvider) =>
1718
new(developerIdProvider);

Diff for: GitHubExtension.Test/DataStoreTests/OctokitIngestionTests.cs

+13-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using GitHubExtension.DataModel.DataObjects;
99
using GitHubExtension.DeveloperId;
1010
using GitHubExtension.Test.Helpers;
11+
using Moq;
1112
using Octokit;
1213

1314
namespace GitHubExtension.Test.DataStoreTests;
@@ -30,7 +31,8 @@ public void AddUserFromOctokit()
3031
"octokit",
3132
};
3233

33-
var client = new GitHubClientProvider(new DeveloperIdProvider()).GetClient();
34+
var mockCredentialVault = new Mock<ICredentialVault>();
35+
var client = new GitHubClientProvider(new DeveloperIdProvider(mockCredentialVault.Object)).GetClient();
3436
using var tx = dataStore.Connection!.BeginTransaction();
3537
foreach (var item in items)
3638
{
@@ -82,7 +84,8 @@ public void AddRepositoryFromOctokit()
8284
Tuple.Create("microsoft", "WindowsAppSDK"),
8385
};
8486

85-
var client = new GitHubClientProvider(new DeveloperIdProvider()).GetClient();
87+
var mockCredentialVault = new Mock<ICredentialVault>();
88+
var client = new GitHubClientProvider(new DeveloperIdProvider(mockCredentialVault.Object)).GetClient();
8689
using var tx = dataStore.Connection!.BeginTransaction();
8790
foreach (var item in items)
8891
{
@@ -154,7 +157,8 @@ public void AddPullRequestFromOctokit()
154157
Tuple.Create("microsoft", "WindowsAppSDK", 3482, 2),
155158
};
156159

157-
var client = new GitHubClientProvider(new DeveloperIdProvider()).GetClient();
160+
var mockCredentialVault = new Mock<ICredentialVault>();
161+
var client = new GitHubClientProvider(new DeveloperIdProvider(mockCredentialVault.Object)).GetClient();
158162
using var tx = dataStore.Connection!.BeginTransaction();
159163

160164
foreach (var repo in repositories)
@@ -249,7 +253,8 @@ public void AddIssueFromOctokit()
249253
Tuple.Create("microsoft", "WindowsAppSDK", 12, 2),
250254
};
251255

252-
var client = new GitHubClientProvider(new DeveloperIdProvider()).GetClient();
256+
var mockCredentialVault = new Mock<ICredentialVault>();
257+
var client = new GitHubClientProvider(new DeveloperIdProvider(mockCredentialVault.Object)).GetClient();
253258
using var tx = dataStore.Connection!.BeginTransaction();
254259

255260
foreach (var repo in repositories)
@@ -326,7 +331,8 @@ public void AddPullRequestLabelFromOctokit()
326331
dataStore.Create();
327332
Assert.IsNotNull(dataStore.Connection);
328333

329-
var client = new GitHubClientProvider(new DeveloperIdProvider()).GetClient();
334+
var mockCredentialVault = new Mock<ICredentialVault>();
335+
var client = new GitHubClientProvider(new DeveloperIdProvider(mockCredentialVault.Object)).GetClient();
330336

331337
using var tx = dataStore.Connection!.BeginTransaction();
332338

@@ -382,7 +388,8 @@ public void AddIssueLabelFromOctokit()
382388
dataStore.Create();
383389
Assert.IsNotNull(dataStore.Connection);
384390

385-
var client = new GitHubClientProvider(new DeveloperIdProvider()).GetClient();
391+
var mockCredentialVault = new Mock<ICredentialVault>();
392+
var client = new GitHubClientProvider(new DeveloperIdProvider(mockCredentialVault.Object)).GetClient();
386393

387394
using var tx = dataStore.Connection!.BeginTransaction();
388395

0 commit comments

Comments
 (0)