зеркало из https://github.com/github/VisualStudio.git
Pass in JoinableTaskContext from unit tests
This commit is contained in:
Родитель
0bfb1b316a
Коммит
e1dda51486
|
@ -33,7 +33,7 @@ namespace GitHub.Services
|
|||
IPackageSettings settings,
|
||||
JoinableTaskContext joinableTaskContext)
|
||||
{
|
||||
makethis.gitHubServiceProvider = gitHubServiceProvider;
|
||||
this.gitHubServiceProvider = gitHubServiceProvider;
|
||||
this.service = service;
|
||||
this.userSettings = settings;
|
||||
JoinableTaskFactory = joinableTaskContext.Factory;
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||
using GitHub.Api;
|
||||
using GitHub.Models;
|
||||
using GitHub.Services;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using Rothko;
|
||||
|
@ -168,7 +169,7 @@ public class RepositoryCloneServiceTests
|
|||
|
||||
return new RepositoryCloneService(operatingSystem, vsGitServices, teamExplorerServices,
|
||||
Substitute.For<IGraphQLClientFactory>(), Substitute.For<IGitHubContextService>(),
|
||||
usageTracker, serviceProvider);
|
||||
usageTracker, serviceProvider, new JoinableTaskContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.ComponentModel.Composition;
|
|||
using System.ComponentModel.Composition.Hosting;
|
||||
using GitHub.Factories;
|
||||
using GitHub.Api;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
|
||||
namespace UnitTests
|
||||
{
|
||||
|
@ -88,7 +89,7 @@ namespace UnitTests
|
|||
var clone = cloneService ?? new RepositoryCloneService(Substitute.For<IOperatingSystem>(),
|
||||
Substitute.For<IVSGitServices>(), Substitute.For<ITeamExplorerServices>(),
|
||||
Substitute.For<IGraphQLClientFactory>(), Substitute.For<IGitHubContextService>(),
|
||||
Substitute.For<IUsageTracker>(), ret);
|
||||
Substitute.For<IUsageTracker>(), ret, new JoinableTaskContext());
|
||||
var create = creationService ?? new RepositoryCreationService(clone);
|
||||
avatarProvider = avatarProvider ?? Substitute.For<IAvatarProvider>();
|
||||
ret.GetService(typeof(IGitService)).Returns(gitservice);
|
||||
|
|
|
@ -16,6 +16,7 @@ using NSubstitute;
|
|||
using NUnit.Framework;
|
||||
using System.Windows.Input;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
|
||||
namespace UnitTests.GitHub.App.ViewModels.GitHubPane
|
||||
{
|
||||
|
@ -613,7 +614,8 @@ namespace UnitTests.GitHub.App.ViewModels.GitHubPane
|
|||
Substitute.For<ISyncSubmodulesCommand>(),
|
||||
Substitute.For<IViewViewModelFactory>(),
|
||||
gitService,
|
||||
Substitute.For<IOpenIssueishDocumentCommand>());
|
||||
Substitute.For<IOpenIssueishDocumentCommand>(),
|
||||
new JoinableTaskContext());
|
||||
vm.InitializeAsync(repository, Substitute.For<IConnection>(), "owner", "repo", 1).Wait();
|
||||
|
||||
return Tuple.Create(vm, pullRequestService);
|
||||
|
|
|
@ -6,6 +6,7 @@ using GitHub.App.Services;
|
|||
using GitHub.Models;
|
||||
using GitHub.Primitives;
|
||||
using GitHub.Services;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
@ -17,7 +18,7 @@ public class LocalRepositoriesTests : TestBaseClass
|
|||
public void RepositoriesShouldInitiallyBeEmpty()
|
||||
{
|
||||
var service = CreateVSGitServices("repo1", "repo2");
|
||||
var target = new LocalRepositories(service);
|
||||
var target = new LocalRepositories(service, new JoinableTaskContext());
|
||||
|
||||
Assert.That(target.Repositories, Is.Empty);
|
||||
}
|
||||
|
@ -26,7 +27,7 @@ public class LocalRepositoriesTests : TestBaseClass
|
|||
public async Task RefreshShouldLoadRepositories()
|
||||
{
|
||||
var service = CreateVSGitServices("repo1", "repo2");
|
||||
var target = new LocalRepositories(service);
|
||||
var target = new LocalRepositories(service, new JoinableTaskContext());
|
||||
|
||||
await target.Refresh();
|
||||
|
||||
|
@ -39,7 +40,7 @@ public class LocalRepositoriesTests : TestBaseClass
|
|||
public async Task RefreshShouldAddNewRepository()
|
||||
{
|
||||
var service = CreateVSGitServices("repo1", "repo2");
|
||||
var target = new LocalRepositories(service);
|
||||
var target = new LocalRepositories(service, new JoinableTaskContext());
|
||||
|
||||
await target.Refresh();
|
||||
|
||||
|
@ -60,7 +61,7 @@ public class LocalRepositoriesTests : TestBaseClass
|
|||
public async Task RefreshShouldRemoveRepository()
|
||||
{
|
||||
var service = CreateVSGitServices("repo1", "repo2");
|
||||
var target = new LocalRepositories(service);
|
||||
var target = new LocalRepositories(service, new JoinableTaskContext());
|
||||
|
||||
await target.Refresh();
|
||||
|
||||
|
@ -83,7 +84,7 @@ public class LocalRepositoriesTests : TestBaseClass
|
|||
Tuple.Create("repo1", GitHubAddress),
|
||||
Tuple.Create("repo2", GitHubAddress),
|
||||
Tuple.Create("repo2", "https://another.com"));
|
||||
var target = new LocalRepositories(service);
|
||||
var target = new LocalRepositories(service, new JoinableTaskContext());
|
||||
|
||||
await target.Refresh();
|
||||
|
||||
|
@ -98,7 +99,7 @@ public class LocalRepositoriesTests : TestBaseClass
|
|||
public async Task GetRepositoriesForAddressShouldSortRepositories()
|
||||
{
|
||||
var service = CreateVSGitServices("c", "a", "b");
|
||||
var target = new LocalRepositories(service);
|
||||
var target = new LocalRepositories(service, new JoinableTaskContext());
|
||||
|
||||
await target.Refresh();
|
||||
var result = target.GetRepositoriesForAddress(HostAddress.Create(GitHubAddress));
|
||||
|
|
|
@ -10,6 +10,7 @@ using GitHub.Extensions;
|
|||
using GitHub.Models;
|
||||
using GitHub.Services;
|
||||
using GitHub.Settings;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using Rothko;
|
||||
|
@ -23,7 +24,7 @@ namespace MetricsTests
|
|||
public void ShouldStartTimer()
|
||||
{
|
||||
var service = Substitute.For<IUsageService>();
|
||||
var target = new UsageTracker(CreateServiceProvider(), service, CreatePackageSettings());
|
||||
var target = new UsageTracker(CreateServiceProvider(), service, CreatePackageSettings(), new JoinableTaskContext());
|
||||
|
||||
service.Received(1).StartTimer(Arg.Any<Func<Task>>(), TimeSpan.FromMinutes(3), TimeSpan.FromDays(1));
|
||||
}
|
||||
|
@ -109,7 +110,8 @@ namespace MetricsTests
|
|||
var target = new UsageTracker(
|
||||
CreateServiceProvider(),
|
||||
usageService,
|
||||
CreatePackageSettings());
|
||||
CreatePackageSettings(),
|
||||
new JoinableTaskContext());
|
||||
|
||||
await target.IncrementCounter(x => x.NumberOfClones);
|
||||
UsageData result = usageService.ReceivedCalls().First(x => x.GetMethodInfo().Name == "WriteLocalData").GetArguments()[0] as UsageData;
|
||||
|
@ -125,7 +127,8 @@ namespace MetricsTests
|
|||
var target = new UsageTracker(
|
||||
CreateServiceProvider(),
|
||||
service,
|
||||
CreatePackageSettings());
|
||||
CreatePackageSettings(),
|
||||
new JoinableTaskContext());
|
||||
|
||||
await target.IncrementCounter(x => x.NumberOfClones);
|
||||
await service.Received(1).WriteLocalData(Arg.Is<UsageData>(data =>
|
||||
|
@ -151,7 +154,8 @@ namespace MetricsTests
|
|||
var target = new UsageTracker(
|
||||
CreateServiceProvider(),
|
||||
service,
|
||||
CreatePackageSettings());
|
||||
CreatePackageSettings(),
|
||||
new JoinableTaskContext());
|
||||
|
||||
await target.IncrementCounter(x => x.NumberOfClones);
|
||||
await service.Received(1).WriteLocalData(Arg.Is<UsageData>(data =>
|
||||
|
@ -173,7 +177,7 @@ namespace MetricsTests
|
|||
service.WhenForAnyArgs(x => x.StartTimer(null, new TimeSpan(), new TimeSpan()))
|
||||
.Do(x => tick = x.ArgAt<Func<Task>>(0));
|
||||
|
||||
var target = new UsageTracker(serviceProvider, service, CreatePackageSettings());
|
||||
var target = new UsageTracker(serviceProvider, service, CreatePackageSettings(), new JoinableTaskContext());
|
||||
|
||||
return Tuple.Create(target, tick);
|
||||
}
|
||||
|
@ -271,7 +275,7 @@ namespace MetricsTests
|
|||
[Test]
|
||||
public async Task GetUserGuidWorks()
|
||||
{
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment);
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment, new JoinableTaskContext());
|
||||
var guid = await usageService.GetUserGuid();
|
||||
Assert.IsTrue(guid.Equals(UserGuid));
|
||||
}
|
||||
|
@ -281,7 +285,7 @@ namespace MetricsTests
|
|||
{
|
||||
File.Delete(userFileName);
|
||||
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment);
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment, new JoinableTaskContext());
|
||||
var guid = await usageService.GetUserGuid();
|
||||
Assert.AreNotEqual(guid, Guid.Empty);
|
||||
}
|
||||
|
@ -289,7 +293,7 @@ namespace MetricsTests
|
|||
[Test]
|
||||
public async Task ReadUsageDataWorks()
|
||||
{
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment);
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment, new JoinableTaskContext());
|
||||
var usageData = await usageService.ReadLocalData();
|
||||
|
||||
Assert.IsNotNull(usageData);
|
||||
|
@ -305,7 +309,7 @@ namespace MetricsTests
|
|||
{
|
||||
File.Delete(usageFileName);
|
||||
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment);
|
||||
var usageService = new UsageService(Substitute.For<IGitHubServiceProvider>(), environment, new JoinableTaskContext());
|
||||
var usageData = await usageService.ReadLocalData();
|
||||
|
||||
Assert.IsNotNull(usageData);
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.ComponentModel.Composition;
|
|||
using System.ComponentModel.Composition.Hosting;
|
||||
using GitHub.Factories;
|
||||
using GitHub.Api;
|
||||
using Microsoft.VisualStudio.Threading;
|
||||
|
||||
namespace UnitTests
|
||||
{
|
||||
|
@ -113,7 +114,7 @@ namespace UnitTests
|
|||
var vsgit = IVSGitServices;
|
||||
var clone = cloneService ?? new RepositoryCloneService(os, vsgit, Substitute.For<ITeamExplorerServices>(),
|
||||
Substitute.For<IGraphQLClientFactory>(), Substitute.For<IGitHubContextService>(),
|
||||
Substitute.For<IUsageTracker>(), ret);
|
||||
Substitute.For<IUsageTracker>(), ret, new JoinableTaskContext());
|
||||
var create = creationService ?? new RepositoryCreationService(clone);
|
||||
avatarProvider = avatarProvider ?? Substitute.For<IAvatarProvider>();
|
||||
ret.GetService(typeof(IGitService)).Returns(gitservice);
|
||||
|
|
Загрузка…
Ссылка в новой задаче