public void AssemblyName() { var setValues = new List <object>(); var project = UnconfiguredProjectFactory.Create(); var data = new PropertyPageData() { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.AssemblyNameProperty, Value = "Blah", SetValues = setValues }; var projectProperties = ProjectPropertiesFactory.Create(project, data); var activeConfiguredProject = ActiveConfiguredProjectFactory.ImplementValue(() => projectProperties); var vsLangProjectProperties = CreateInstance(Mock.Of <VSLangProj.VSProject>(), IProjectThreadingServiceFactory.Create(), activeConfiguredProject); Assert.Equal("Blah", vsLangProjectProperties.AssemblyName); var testValue = "Testing"; vsLangProjectProperties.AssemblyName = testValue; Assert.Equal(setValues.Single(), testValue); }
public async Task GetCommandStatusAsync_FolderAsNodes_ReturnsHandled() { var projectProperties = ProjectPropertiesFactory.Create(IUnconfiguredProjectFactory.Create(), new[] { new PropertyPageData { Category = "Project", PropertyName = "ProjectGuid", Value = Guid.NewGuid().ToString() } }); var command = CreateInstance(provider: IProjectTreeProviderFactory.Create(""), dlg: IVsAddProjectItemDlgFactory.Create(0), properties: () => projectProperties); var tree = ProjectTreeParser.Parse(@" Root (flags: {ProjectRoot}) Code (flags: {Folder}) "); var nodes = ImmutableHashSet.Create(tree.Children[0]); var result = await command.GetCommandStatusAsync(nodes, GetCommandId(), true, "commandText", (CommandStatus)0); Assert.True(result.Handled); Assert.Equal("commandText", result.CommandText); Assert.Equal(CommandStatus.Enabled | CommandStatus.Supported, result.Status); }
ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = null) { _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", ""); _mockFS.CreateDirectory(@"c:\test\Project"); _mockFS.CreateDirectory(@"c:\test\Project\bin\"); _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", ""); LaunchProfile activeProfile = new LaunchProfile() { Name = "MyApplication", CommandLineArgs = "--someArgs", ExecutablePath = @"c:\test\Project\someapp.exe" }; _mockEnvironment.Setup(s => s.GetEnvironmentVariable("Path")).Returns(() => _Path); var project = UnconfiguredProjectFactory.Create(null, null, _ProjectFile); var outputTypeEnum = new PageEnumValue(new EnumValue() { Name = outputType }); var data = new PropertyPageData() { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.OutputTypeProperty, Value = outputTypeEnum }; var projectProperties = ProjectPropertiesFactory.Create(project, data); if (properties == null) { properties = new Dictionary <string, string>() { { "RunCommand", @"dotnet" }, { "RunArguments", "exec " + "\"" + @"c:\test\project\bin\project.dll" + "\"" }, { "RunWorkingDirectory", @"bin\" }, { "TargetFrameworkIdentifier", @".NetCoreApp" } }; } var delegatePropertiesMock = IProjectPropertiesFactory .MockWithPropertiesAndValues(properties); var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object); IConfiguredProjectServices configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o => o.ProjectPropertiesProvider == delegateProvider); ConfiguredProject configuredProject = Mock.Of <ConfiguredProject>(o => o.UnconfiguredProject == project && o.Services == configuredProjectServices); _mockTokenReplace.Setup(s => s.ReplaceTokensInProfileAsync(It.IsAny <ILaunchProfile>())).Returns <ILaunchProfile>(p => Task.FromResult(p)); IActiveDebugFrameworkServices activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>(o => o.GetConfiguredProjectForActiveFrameworkAsync() == Task.FromResult(configuredProject)); var debugProvider = new ConsoleDebugTargetsProvider( configuredProject, _mockTokenReplace.Object, _mockFS, _mockEnvironment.Object, activeDebugFramework, projectProperties); return(debugProvider); }
private static ProjectProperties CreateProperties(string appDesignerFolderName) { return(ProjectPropertiesFactory.Create(UnconfiguredProjectFactory.Create(), new[] { new PropertyPageData(AppDesigner.SchemaName, AppDesigner.FolderNameProperty, appDesignerFolderName) })); }
public void VerifyFileWatcherRegistrationOnTreeChange(string inputTree, string changedTree, int numRegisterCalls, int numUnregisterCalls) { var spMock = new IServiceProviderMoq(); uint adviseCookie = 100; var fileChangeService = IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(adviseCookie); spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), fileChangeService); var propertyData = new PropertyPageData { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.BaseIntermediateOutputPathProperty, Value = "obj\\" }; var unconfiguredProject = IUnconfiguredProjectFactory.Create(filePath: @"C:\Foo\foo.proj"); var watcher = new ProjectLockFileWatcher(spMock, IProjectTreeProviderFactory.Create(), IUnconfiguredProjectCommonServicesFactory.Create(unconfiguredProject, projectProperties: ProjectPropertiesFactory.Create(unconfiguredProject, new[] { propertyData })), IProjectLockServiceFactory.Create()); watcher.Load(); var firstTree = ProjectTreeParser.Parse(inputTree); watcher.ProjectTree_ChangedAsync(IProjectVersionedValueFactory <IProjectTreeSnapshot> .Create(IProjectTreeSnapshotFactory.Create(firstTree))); var secondTree = ProjectTreeParser.Parse(changedTree); watcher.ProjectTree_ChangedAsync(IProjectVersionedValueFactory <IProjectTreeSnapshot> .Create(IProjectTreeSnapshotFactory.Create(secondTree))); // If fileToWatch is null then we expect to not register any filewatcher. Mock <IVsFileChangeEx> fileChangeServiceMock = Mock.Get <IVsFileChangeEx>(fileChangeService); fileChangeServiceMock.Verify(s => s.AdviseFileChange(It.IsAny <string>(), It.IsAny <uint>(), watcher, out adviseCookie), Times.Exactly(numRegisterCalls)); fileChangeServiceMock.Verify(s => s.UnadviseFileChange(adviseCookie), Times.Exactly(numUnregisterCalls)); }
public void VerifyFileWatcherRegistration(string inputTree, string fileToWatch) { var spMock = new IServiceProviderMoq(); uint adviseCookie = 100; var fileChangeService = IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(adviseCookie); spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), fileChangeService); var propertyData = CreateBaseIntermediateOutputPathProperty("obj\\"); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: @"C:\Foo\foo.proj"); var watcher = new ProjectAssetFileWatcher(spMock, IProjectTreeProviderFactory.Create(), IUnconfiguredProjectCommonServicesFactory.Create(unconfiguredProject, projectProperties: ProjectPropertiesFactory.Create(unconfiguredProject, new[] { propertyData })), IProjectLockServiceFactory.Create()); var tree = ProjectTreeParser.Parse(inputTree); watcher.Load(); watcher.ProjectTree_ChangedAsync(IProjectVersionedValueFactory <IProjectTreeSnapshot> .Create(IProjectTreeSnapshotFactory.Create(tree))); // If fileToWatch is null then we expect to not register any filewatcher. var times = fileToWatch == null?Times.Never() : Times.Once(); Mock.Get(fileChangeService).Verify(s => s.AdviseFileChange(fileToWatch ?? It.IsAny <string>(), It.IsAny <uint>(), watcher, out adviseCookie), times); }
public void WhenBaseIntermediateOutputPathNotSet_DoesNotAttemptToAdviseFileChange() { var spMock = new IServiceProviderMoq(); var fileChangeService = IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100); spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), fileChangeService); var propertyData = CreateBaseIntermediateOutputPathProperty(string.Empty); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: @"C:\Foo\foo.proj"); var watcher = new ProjectAssetFileWatcher(spMock, IProjectTreeProviderFactory.Create(), IUnconfiguredProjectCommonServicesFactory.Create(unconfiguredProject, projectProperties: ProjectPropertiesFactory.Create(unconfiguredProject, new[] { propertyData })), IProjectLockServiceFactory.Create()); var tree = ProjectTreeParser.Parse(@"Root (flags: {ProjectRoot}), FilePath: ""C:\Foo\foo.proj"""); watcher.Load(); watcher.ProjectTree_ChangedAsync(IProjectVersionedValueFactory <IProjectTreeSnapshot> .Create(IProjectTreeSnapshotFactory.Create(tree))); Mock <IVsFileChangeEx> fileChangeServiceMock = Mock.Get(fileChangeService); uint cookie; fileChangeServiceMock.Verify(s => s.AdviseFileChange(It.IsAny <string>(), It.IsAny <uint>(), watcher, out cookie), Times.Never()); }