16 changed files with 444 additions and 120 deletions
@ -0,0 +1,115 @@
@@ -0,0 +1,115 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Design |
||||
{ |
||||
public class FakeSettings : ISettings |
||||
{ |
||||
public List<KeyValuePair<string, string>> PackageSources |
||||
= new List<KeyValuePair<string, string>>(); |
||||
|
||||
public List<KeyValuePair<string, string>> ActivePackageSourceSettings = |
||||
new List<KeyValuePair<string, string>>(); |
||||
|
||||
public Dictionary<string, IList<KeyValuePair<string, string>>> Sections |
||||
= new Dictionary<string, IList<KeyValuePair<string, string>>>(); |
||||
|
||||
public FakeSettings() |
||||
{ |
||||
Sections.Add(RegisteredPackageSources.PackageSourcesSectionName, PackageSources); |
||||
Sections.Add(RegisteredPackageSources.ActivePackageSourceSectionName, ActivePackageSourceSettings); |
||||
} |
||||
|
||||
public string GetValue(string section, string key) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IList<KeyValuePair<string, string>> GetValues(string section) |
||||
{ |
||||
return Sections[section]; |
||||
} |
||||
|
||||
public void AddFakePackageSource(PackageSource packageSource) |
||||
{ |
||||
var valuePair = new KeyValuePair<string, string>(packageSource.Name, packageSource.Source); |
||||
PackageSources.Add(valuePair); |
||||
} |
||||
|
||||
public Dictionary<string, KeyValuePair<string, string>> SavedSectionValues = |
||||
new Dictionary<string, KeyValuePair<string, string>>(); |
||||
|
||||
public void SetValue(string section, string key, string value) |
||||
{ |
||||
SavedSectionValues.Remove(section); |
||||
SavedSectionValues.Add(section, new KeyValuePair<string, string>(key, value)); |
||||
} |
||||
|
||||
public KeyValuePair<string, string> GetValuePassedToSetValueForActivePackageSourceSection() |
||||
{ |
||||
return SavedSectionValues[RegisteredPackageSources.ActivePackageSourceSectionName]; |
||||
} |
||||
|
||||
public void SetValues(string section, IList<KeyValuePair<string, string>> values) |
||||
{ |
||||
SavedSectionValueLists.Remove(section); |
||||
SavedSectionValueLists.Add(section, values); |
||||
} |
||||
|
||||
public Dictionary<string, IList<KeyValuePair<string, string>>> SavedSectionValueLists |
||||
= new Dictionary<string, IList<KeyValuePair<string, string>>>(); |
||||
|
||||
public IList<KeyValuePair<string, string>> GetValuesPassedToSetValuesForPackageSourcesSection() |
||||
{ |
||||
return SavedSectionValueLists[RegisteredPackageSources.PackageSourcesSectionName]; |
||||
} |
||||
|
||||
public bool DeleteValue(string section, string key) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public List<string> SectionsDeleted = new List<string>(); |
||||
|
||||
public bool DeleteSection(string section) |
||||
{ |
||||
SectionsDeleted.Add(section); |
||||
return true; |
||||
} |
||||
|
||||
public bool IsPackageSourcesSectionDeleted { |
||||
get { |
||||
return SectionsDeleted.Contains(RegisteredPackageSources.PackageSourcesSectionName); |
||||
} |
||||
} |
||||
|
||||
public bool IsActivePackageSourceSectionDeleted { |
||||
get { |
||||
return SectionsDeleted.Contains(RegisteredPackageSources.ActivePackageSourceSectionName); |
||||
} |
||||
} |
||||
|
||||
public void SetFakeActivePackageSource(PackageSource packageSource) |
||||
{ |
||||
ActivePackageSourceSettings.Clear(); |
||||
var valuePair = new KeyValuePair<string, string>(packageSource.Name, packageSource.Source); |
||||
ActivePackageSourceSettings.Add(valuePair); |
||||
} |
||||
|
||||
public void MakeActivePackageSourceSectionNull() |
||||
{ |
||||
Sections.Remove(RegisteredPackageSources.ActivePackageSourceSectionName); |
||||
Sections.Add(RegisteredPackageSources.ActivePackageSourceSectionName, null); |
||||
} |
||||
|
||||
public void MakePackageSourceSectionsNull() |
||||
{ |
||||
Sections.Remove(RegisteredPackageSources.PackageSourcesSectionName); |
||||
Sections.Add(RegisteredPackageSources.PackageSourcesSectionName, null); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.PackageManagement; |
||||
using ICSharpCode.PackageManagement.Design; |
||||
|
||||
namespace PackageManagement.Tests.Helpers |
||||
{ |
||||
public class TestablePackageManagementOptions : PackageManagementOptions |
||||
{ |
||||
public Properties Properties; |
||||
public FakeSettings FakeSettings; |
||||
|
||||
public TestablePackageManagementOptions() |
||||
: this(new Properties(), new FakeSettings()) |
||||
{ |
||||
} |
||||
|
||||
public TestablePackageManagementOptions(Properties properties, FakeSettings fakeSettings) |
||||
: base(properties, fakeSettings) |
||||
{ |
||||
this.Properties = properties; |
||||
this.FakeSettings = fakeSettings; |
||||
} |
||||
} |
||||
} |
||||
@ -1,66 +0,0 @@
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PackageManagement; |
||||
using ICSharpCode.Core; |
||||
using NuGet; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PackageManagement.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class RegisteredPackageSourcesTests |
||||
{ |
||||
RegisteredPackageSources registeredPackageSources; |
||||
PackageManagementOptions options; |
||||
Properties properties; |
||||
|
||||
void CreateProperties() |
||||
{ |
||||
properties = new Properties(); |
||||
} |
||||
|
||||
void CreateRegisteredPackageSources() |
||||
{ |
||||
CreateProperties(); |
||||
CreateRegisteredPackageSources(properties); |
||||
} |
||||
|
||||
void CreateRegisteredPackageSources(Properties properties) |
||||
{ |
||||
options = new PackageManagementOptions(properties); |
||||
registeredPackageSources = options.PackageSources; |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_NoExistingSavedProperties_NewInstanceContainsDefaultPackageSource() |
||||
{ |
||||
CreateRegisteredPackageSources(); |
||||
|
||||
List<PackageSource> expectedSources = new List<PackageSource>(); |
||||
expectedSources.Add(RegisteredPackageSources.DefaultPackageSource); |
||||
|
||||
CollectionAssert.AreEqual(expectedSources, registeredPackageSources); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_OnePackageSourceInSavedProperties_NewInstanceContainsSinglePackageSourceFromProperties() |
||||
{ |
||||
CreateProperties(); |
||||
CreateRegisteredPackageSources(properties); |
||||
|
||||
var packageSource = new PackageSource("http://codeplex.com", "Test"); |
||||
registeredPackageSources.Clear(); |
||||
registeredPackageSources.Add(packageSource); |
||||
|
||||
CreateRegisteredPackageSources(properties); |
||||
|
||||
List<PackageSource> expectedSources = new List<PackageSource>(); |
||||
expectedSources.Add(packageSource); |
||||
|
||||
Assert.AreEqual(expectedSources, registeredPackageSources); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue