PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/ajadex/SharpDevelop
C# | 235 lines | 174 code | 44 blank | 17 comment | 0 complexity | edd401b039058b8a8ef604db5ca30bdc 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
 19using System;
 20using System.Collections.Generic;
 21using System.Linq;
 22using ICSharpCode.PackageManagement;
 23using NuGet;
 24
 25namespace ICSharpCode.PackageManagement.Design
 26{
 27	public class FakePackageManager : ISharpDevelopPackageManager
 28	{
 29		public FakeProjectManager FakeProjectManager = new FakeProjectManager();
 30		public FakePackageManagementProjectService FakeProjectService = new FakePackageManagementProjectService();
 31		
 32		public bool IsRefreshProjectBrowserCalledWhenInstallPackageCalled;
 33		public bool IsRefreshProjectBrowserCalledWhenUninstallPackageCalled;
 34		
 35		public IPackage PackagePassedToInstallPackage;
 36		public bool IgnoreDependenciesPassedToInstallPackage;
 37		public bool AllowPrereleaseVersionsPassedToInstallPackage;
 38		
 39		public IPackage PackagePassedToUninstallPackage;
 40		
 41		public UpdatePackagesAction UpdatePackagesActionsPassedToUpdatePackages;
 42		
 43		#pragma warning disable 67
 44		public event EventHandler<PackageOperationEventArgs> PackageInstalled;
 45		public event EventHandler<PackageOperationEventArgs> PackageInstalling;
 46		public event EventHandler<PackageOperationEventArgs> PackageUninstalled;
 47		public event EventHandler<PackageOperationEventArgs> PackageUninstalling;
 48		#pragma warning restore 67
 49		
 50		public IFileSystem FileSystem {
 51			get { return FakeFileSystem; }
 52			set { FakeFileSystem = value as FakeFileSystem; }
 53		}
 54		
 55		public FakeFileSystem FakeFileSystem = new FakeFileSystem();
 56		
 57		public IPackageRepository LocalRepository { get; set; }
 58		public ILogger Logger { get; set; }
 59		public IPackageRepository SourceRepository { get; set; }
 60		public ISharpDevelopProjectManager ProjectManager { get; set; }
 61		
 62		public FakePackageRepository FakeSourceRepository = new FakePackageRepository();
 63		
 64		public FakePackageManager()
 65		{
 66			ProjectManager = FakeProjectManager;
 67			SourceRepository = FakeSourceRepository;
 68		}
 69		
 70		public bool ForceRemovePassedToUninstallPackage;
 71		public bool RemoveDependenciesPassedToUninstallPackage;
 72		
 73		public void UninstallPackage(IPackage package, UninstallPackageAction uninstallAction)
 74		{
 75			PackagePassedToUninstallPackage = package;
 76			ForceRemovePassedToUninstallPackage = uninstallAction.ForceRemove;
 77			RemoveDependenciesPassedToUninstallPackage = uninstallAction.RemoveDependencies;
 78			IsRefreshProjectBrowserCalledWhenUninstallPackageCalled = FakeProjectService.IsRefreshProjectBrowserCalled;
 79		}
 80		
 81		public void UninstallPackage(IPackage package, bool forceRemove, bool removeDependencies)
 82		{
 83			throw new NotImplementedException();
 84		}
 85		
 86		public IEnumerable<PackageOperation> PackageOperationsPassedToInstallPackage;
 87		
 88		public void InstallPackage(IPackage package, InstallPackageAction installAction)
 89		{
 90			PackagePassedToInstallPackage = package;
 91			
 92			IgnoreDependenciesPassedToInstallPackage = installAction.IgnoreDependencies;
 93			PackageOperationsPassedToInstallPackage = installAction.Operations;
 94			AllowPrereleaseVersionsPassedToInstallPackage = installAction.AllowPrereleaseVersions;
 95			
 96			IsRefreshProjectBrowserCalledWhenInstallPackageCalled = FakeProjectService.IsRefreshProjectBrowserCalled;
 97		}
 98		
 99		public List<PackageOperation> PackageOperationsToReturnFromGetInstallPackageOperations = new List<PackageOperation>();
100		public IPackage PackagePassedToGetInstallPackageOperations;
101		public bool IgnoreDependenciesPassedToGetInstallPackageOperations;
102		public bool AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
103		
104		public IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, InstallPackageAction installAction)
105		{
106			PackagePassedToGetInstallPackageOperations = package;
107			IgnoreDependenciesPassedToGetInstallPackageOperations = installAction.IgnoreDependencies;
108			AllowPrereleaseVersionsPassedToGetInstallPackageOperations = installAction.AllowPrereleaseVersions;
109			return PackageOperationsToReturnFromGetInstallPackageOperations;
110		}
111		
112		public IPackage PackagePassedToUpdatePackage;
113		public IEnumerable<PackageOperation> PackageOperationsPassedToUpdatePackage;
114		public bool UpdateDependenciesPassedToUpdatePackage;
115		
116		public void UpdatePackage(IPackage package, UpdatePackageAction updateAction)
117		{
118			PackagePassedToUpdatePackage = package;
119			PackageOperationsPassedToUpdatePackage = updateAction.Operations;
120			UpdateDependenciesPassedToUpdatePackage = updateAction.UpdateDependencies;
121			AllowPrereleaseVersionsPassedToInstallPackage = updateAction.AllowPrereleaseVersions;
122		}
123		
124		public void FirePackageInstalled(PackageOperationEventArgs e)
125		{
126			PackageInstalled(this, e);
127		}
128		
129		public void FirePackageUninstalled(PackageOperationEventArgs e)
130		{
131			PackageUninstalled(this, e);
132		}
133		
134		public IPackagePathResolver PathResolver {
135			get {
136				throw new NotImplementedException();
137			}
138		}
139		
140		public void UpdatePackage(IPackage newPackage, bool updateDependencies)
141		{
142			throw new NotImplementedException();
143		}
144		
145		public void UpdatePackage(string packageId, IVersionSpec versionSpec, bool updateDependencies)
146		{
147			throw new NotImplementedException();
148		}
149		
150		public void InstallPackage(IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions)
151		{
152			throw new NotImplementedException();
153		}
154		
155		public void InstallPackage(string packageId, SemanticVersion version, bool ignoreDependencies, bool allowPrereleaseVersions)
156		{
157			throw new NotImplementedException();
158		}
159		
160		public void UpdatePackage(IPackage newPackage, bool updateDependencies, bool allowPrereleaseVersions)
161		{
162			throw new NotImplementedException();
163		}
164		
165		public void UpdatePackage(string packageId, SemanticVersion version, bool updateDependencies, bool allowPrereleaseVersions)
166		{
167			throw new NotImplementedException();
168		}
169		
170		public void UpdatePackage(string packageId, IVersionSpec versionSpec, bool updateDependencies, bool allowPrereleaseVersions)
171		{
172			throw new NotImplementedException();
173		}
174		
175		public void UninstallPackage(string packageId, SemanticVersion version, bool forceRemove, bool removeDependencies)
176		{
177			throw new NotImplementedException();
178		}
179		
180		public void UpdatePackages(UpdatePackagesAction updateAction)
181		{
182			UpdatePackagesActionsPassedToUpdatePackages = updateAction;
183		}
184		
185		public List<PackageOperation> PackageOperationsToReturnFromGetUpdatePackageOperations = new List<PackageOperation>();
186		public IUpdatePackageSettings SettingsPassedToGetUpdatePackageOperations;
187		public IEnumerable<IPackage> PackagesPassedToGetUpdatePackageOperations;
188		
189		public IEnumerable<PackageOperation> GetUpdatePackageOperations(IEnumerable<IPackage> packages, IUpdatePackageSettings settings)
190		{
191			SettingsPassedToGetUpdatePackageOperations = settings;
192			PackagesPassedToGetUpdatePackageOperations = packages;
193			return PackageOperationsToReturnFromGetUpdatePackageOperations;
194		}
195		
196		public List<PackageOperation> PackageOperationsPassedToRunPackageOperations;
197		
198		public void RunPackageOperations(IEnumerable<PackageOperation> operations)
199		{
200			PackageOperationsPassedToRunPackageOperations = operations.ToList();
201		}
202		
203		public IPackage PackagePassedToUpdatePackageReference;
204		public IUpdatePackageSettings SettingsPassedToUpdatePackageReference;
205		
206		public void UpdatePackageReference(IPackage package, IUpdatePackageSettings settings)
207		{
208			PackagePassedToUpdatePackageReference = package;
209			SettingsPassedToUpdatePackageReference = settings;
210		}
211		
212		public void InstallPackage(IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions, bool ignoreWalkInfo)
213		{
214			throw new NotImplementedException();
215		}
216		
217		public DependencyVersion DependencyVersion {
218			get {
219				throw new NotImplementedException();
220			}
221			set {
222				throw new NotImplementedException();
223			}
224		}
225		
226		public bool WhatIf {
227			get {
228				throw new NotImplementedException();
229			}
230			set {
231				throw new NotImplementedException();
232			}
233		}
234	}
235}