/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeRegisteredPackageRepositories.cs

https://github.com/ajadex/SharpDevelop · C# · 112 lines · 74 code · 21 blank · 17 comment · 0 complexity · c0cb9a0f1d0acf837e0484187831e2c3 MD5 · raw file

  1. // Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy of this
  4. // software and associated documentation files (the "Software"), to deal in the Software
  5. // without restriction, including without limitation the rights to use, copy, modify, merge,
  6. // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
  7. // to whom the Software is furnished to do so, subject to the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be included in all copies or
  10. // substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  13. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  14. // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  15. // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17. // DEALINGS IN THE SOFTWARE.
  18. using System;
  19. using System.Collections.Generic;
  20. using NuGet;
  21. namespace ICSharpCode.PackageManagement.Design
  22. {
  23. public class FakeRegisteredPackageRepositories : IRegisteredPackageRepositories
  24. {
  25. public FakeRegisteredPackageRepositories()
  26. {
  27. PackageSources = new RegisteredPackageSources(new PackageSource[0]);
  28. }
  29. public FakePackageRepository FakeActiveRepository = new FakePackageRepository();
  30. public virtual IPackageRepository ActiveRepository {
  31. get { return FakeActiveRepository; }
  32. }
  33. public FakePackageRepository FakeRecentPackageRepository = new FakePackageRepository();
  34. public virtual IRecentPackageRepository RecentPackageRepository {
  35. get { return FakeRecentPackageRepository; }
  36. }
  37. public bool HasMultiplePackageSources { get; set; }
  38. public PackageSource ActivePackageSource { get; set; }
  39. public RegisteredPackageSources PackageSources { get; set; }
  40. public FakePackageRepository FakePackageRepository = new FakePackageRepository();
  41. public PackageSource PackageSourcePassedToCreateRepository;
  42. public IPackageRepository CreateRepository(PackageSource source)
  43. {
  44. PackageSourcePassedToCreateRepository = source;
  45. return FakePackageRepository;
  46. }
  47. public FakePackageRepository FakeAggregateRepository = new FakePackageRepository();
  48. public IPackageRepository CreateAggregateRepository()
  49. {
  50. return FakeAggregateRepository;
  51. }
  52. public void ClearPackageSources()
  53. {
  54. PackageSources.Clear();
  55. }
  56. public PackageSource AddOnePackageSource()
  57. {
  58. return AddOnePackageSource("Test");
  59. }
  60. public PackageSource AddOnePackageSource(string name)
  61. {
  62. var source = new PackageSource("http://sharpdevelop.codeplex.com", name);
  63. PackageSources.Add(source);
  64. return source;
  65. }
  66. public void AddPackageSources(IEnumerable<PackageSource> sources)
  67. {
  68. PackageSources.AddRange(sources);
  69. }
  70. public FakePackage AddFakePackageWithVersionToActiveRepository(string version)
  71. {
  72. return AddFakePackageWithVersionToActiveRepository("Test", version);
  73. }
  74. public FakePackage AddFakePackageWithVersionToActiveRepository(string id, string version)
  75. {
  76. var package = FakePackage.CreatePackageWithVersion(id, version);
  77. FakeActiveRepository.FakePackages.Add(package);
  78. return package;
  79. }
  80. public FakePackage AddFakePackageWithVersionToAggregrateRepository(string id, string version)
  81. {
  82. var package = FakePackage.CreatePackageWithVersion(id, version);
  83. FakeAggregateRepository.FakePackages.Add(package);
  84. return package;
  85. }
  86. public void UpdatePackageSources(IEnumerable<PackageSource> updatedPackageSources)
  87. {
  88. throw new NotImplementedException();
  89. }
  90. }
  91. }