public void Clone_CopiesAllPropertyValuesFromSource() { // Arrange var credentials = new PackageSourceCredential("SourceName", "username", "password", isPasswordClearText: false, validAuthenticationTypesText: null); var source = new PackageSource("Source", "SourceName", isEnabled: false) { Credentials = credentials, ProtocolVersion = 43 }; // Act var result = source.Clone(); // Assert // source data Assert.Equal(source.Source, result.Source); Assert.Equal(source.Name, result.Name); Assert.Equal(source.IsEnabled, result.IsEnabled); Assert.Equal(source.ProtocolVersion, result.ProtocolVersion); // source credential result.Credentials.Should().NotBeNull(); result.Credentials.Source.Should().BeEquivalentTo(source.Credentials.Source); result.Credentials.Username.Should().BeEquivalentTo(source.Credentials.Username); result.Credentials.IsPasswordClearText.Should().Be(source.Credentials.IsPasswordClearText); }
private void EnsureInitialized() { if (_initialized) { return; } lock (this) { if (_initialized) { return; } _packageSources = _packageSourceProvider.LoadPackageSources().ToList(); // When running Visual Studio Express for Windows 8, we insert the curated feed at the top if (_vsShellInfo.IsVisualStudioExpressForWindows8) { bool windows8SourceIsEnabled = _packageSourceProvider.IsPackageSourceEnabled(Windows8Source); // defensive coding: make sure we don't add duplicated win8 source _packageSources.RemoveAll(p => p.Equals(Windows8Source)); // Windows8Source is a static object which is meant for doing comparison only. // To add it to the list of package sources, we make a clone of it first. var windows8SourceClone = Windows8Source.Clone(); windows8SourceClone.IsEnabled = windows8SourceIsEnabled; _packageSources.Insert(0, windows8SourceClone); } InitializeActivePackageSource(); _initialized = true; } }
private void EnsureInitialized() { if (!_initialized) { _initialized = true; _packageSources = _packageSourceProvider.LoadPackageSources().ToList(); // Unlike NuGet Core, Visual Studio has the concept of an official package source. // We find the official source, if present, and set its IsOfficial it. var officialPackageSource = _packageSources.FirstOrDefault(packageSource => IsOfficialPackageSource(packageSource)); if (officialPackageSource != null) { officialPackageSource.IsOfficial = true; } // When running Visual Studio Express for Windows 8, we insert the curated feed at the top if (_vsShellInfo.IsVisualStudioExpressForWindows8) { bool windows8SourceIsEnabled = _packageSourceProvider.IsPackageSourceEnabled(Windows8Source); // defensive coding: make sure we don't add duplicated win8 source _packageSources.RemoveAll(p => p.Equals(Windows8Source)); // Windows8Source is a static object which is meant for doing comparison only. // To add it to the list of package sources, we make a clone of it first. var windows8SourceClone = Windows8Source.Clone(); windows8SourceClone.IsEnabled = windows8SourceIsEnabled; _packageSources.Insert(0, windows8SourceClone); } InitializeActivePackageSource(); } }
public PackageSourceViewModel(PackageSource packageSource) { this.packageSource = packageSource.Clone(); Name = packageSource.Name; Password = packageSource.Password; IsValid = true; ValidationFailureMessage = ""; }
public void Clone_CopiesAllPropertyValuesFromSource() { // Arrange var source = new PackageSource("Source", "SourceName", isEnabled: false) { IsPasswordClearText = true, Password = "******", UserName = "******", ProtocolVersion = 43, }; // Act var result = source.Clone(); // Assert Assert.Equal(source.Source, result.Source); Assert.Equal(source.Name, result.Name); Assert.Equal(source.IsEnabled, result.IsEnabled); Assert.Equal(source.ProtocolVersion, result.ProtocolVersion); Assert.Equal(source.UserName, result.UserName); Assert.Equal(source.Password, source.Password); }