public async Task AllowProjectLoadAsync_WhenUnrecognizedExtension_ReturnsTrue(string fullPath) { var project = UnconfiguredProjectFactory.ImplementFullPath(fullPath); var capabilitiesService = IProjectCapabilitiesServiceFactory.ImplementsContains(c => throw new Exception("Should not be hit")); var veto = CreateInstance(project, capabilitiesService); var result = await veto.AllowProjectLoadAsync(true, ProjectConfigurationFactory.Create("Debug|AnyCPU"), CancellationToken.None); Assert.True(result); }
public async Task AllowProjectLoadAsync_WhenMissingCapability_ReturnsFail(string fullPath) { var project = UnconfiguredProjectFactory.ImplementFullPath(fullPath); var capabilitiesService = IProjectCapabilitiesServiceFactory.ImplementsContains(c => false); var veto = CreateInstance(project, capabilitiesService); var result = await Assert.ThrowsAnyAsync <Exception>(() => { return(veto.AllowProjectLoadAsync(true, ProjectConfigurationFactory.Create("Debug|AnyCPU"), CancellationToken.None)); }); Assert.Equal(VSConstants.E_FAIL, result.HResult); }
private static ApplyChangesToWorkspaceContext CreateInstance(ConfiguredProject?project = null, ICommandLineParserService?commandLineParser = null, IProjectLogger?logger = null, params IWorkspaceContextHandler[] handlers) { if (project == null) { var unconfiguredProject = UnconfiguredProjectFactory.ImplementFullPath(@"C:\Project\Project.csproj"); project = ConfiguredProjectFactory.ImplementUnconfiguredProject(unconfiguredProject); } commandLineParser ??= ICommandLineParserServiceFactory.Create(); logger ??= IProjectLoggerFactory.Create(); var factories = handlers.Select(h => ExportFactoryFactory.ImplementCreateValueWithAutoDispose(() => h)) .ToArray(); var applyChangesToWorkspaceContext = new ApplyChangesToWorkspaceContext(project, logger, factories); applyChangesToWorkspaceContext.CommandLineParsers.Add(commandLineParser); return(applyChangesToWorkspaceContext); }
private static EvaluationCommandLineHandler CreateInstance(string fullPath = null) { var project = UnconfiguredProjectFactory.ImplementFullPath(fullPath); return(new EvaluationCommandLineHandler(project)); }
/// <summary> /// Creates an <see cref="UnconfiguredProject"/> where the <see cref="UnconfiguredProject.FullPath"/> /// is set to <see cref="DefaultTestProjectPath"/>. /// </summary> private static UnconfiguredProject CreateDefaultTestProject() { return(UnconfiguredProjectFactory.ImplementFullPath(DefaultTestProjectPath)); }