Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FakePackage.cs « MonoDevelop.PackageManagement.Tests.Helpers « MonoDevelop.PackageManagement.Tests « MonoDevelop.PackageManagement « addins « src « main - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4601469c9bf9d164927609d7b6a6b9800633f308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
//
// FakePackage.cs
//
// Author:
//       Matt Ward <matt.ward@xamarin.com>
//
// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Versioning;
using ICSharpCode.PackageManagement;
using NuGet;

namespace MonoDevelop.PackageManagement.Tests.Helpers
{
	public class FakePackage : IPackageFromRepository
	{
		public Stream Stream = null;
		public List<string> AuthorsList = new List<string> ();
		public List<string> OwnersList = new List<string> ();
		public List<IPackageFile> FilesList = new List<IPackageFile> ();

		public List<PackageDependency> DependenciesList = 
			new List<PackageDependency> ();

		public List<IPackageAssemblyReference> AssemblyReferenceList =
			new List<IPackageAssemblyReference> ();

		public FakePackage ()
			: this (String.Empty)
		{
		}

		public FakePackage (string id)
			: this (id, "1.0.0.0")
		{
		}

		public FakePackage (string id, string version)
		{
			this.Id = id;
			this.Description = String.Empty;
			this.Version = new SemanticVersion (version);
			this.Listed = true;
			this.IsLatestVersion = true;
		}

		public static FakePackage CreatePackageWithVersion (string version)
		{
			return CreatePackageWithVersion ("Test", version);
		}

		public static FakePackage CreatePackageWithVersion (string id, string version)
		{
			return new FakePackage (id, version);
		}

		public string Id { get; set; }
		public SemanticVersion Version { get; set; }
		public string Title { get; set; }
		public Uri IconUrl { get; set; }
		public Uri LicenseUrl { get; set; }
		public Uri ProjectUrl { get; set; }
		public bool RequireLicenseAcceptance { get; set; }
		public string Description { get; set; }
		public string Summary { get; set; }
		public string Language { get; set; }
		public string Tags { get; set; }
		public Uri ReportAbuseUrl { get; set; }
		public int DownloadCount { get; set; }
		public int RatingsCount { get; set; }
		public double Rating { get; set; }

		public IEnumerable<IPackageAssemblyReference> AssemblyReferences {
			get { return AssemblyReferenceList; }
		}

		public IEnumerable<string> Authors {
			get { return AuthorsList; }
		}

		public IEnumerable<string> Owners {
			get { return OwnersList; }
		}

		public IEnumerable<IPackageFile> GetFiles ()
		{
			return FilesList;
		}

		public Stream GetStream ()
		{
			return Stream;
		}

		public override string ToString ()
		{
			return String.Format ("{0} {1}", Id, Version);
		}

		public override bool Equals (object obj)
		{
			IPackage rhs = obj as IPackage;
			if (rhs != null) {
				return (Id == rhs.Id) && (Version == rhs.Version);
			}
			return false;
		}

		public override int GetHashCode ()
		{
			return base.GetHashCode ();
		}

		public void AddAuthor (string author)
		{
			AuthorsList.Add (author);
		}

		public void AddDependency (string id, SemanticVersion minVersion, SemanticVersion maxVersion)
		{
			var versionSpec = new VersionSpec ();
			versionSpec.MinVersion = minVersion;
			versionSpec.MaxVersion = maxVersion;
			var dependency = new PackageDependency (id, versionSpec);
			DependenciesList.Add (dependency);
		}

		public void AddDependency (string id)
		{
			DependenciesList.Add (new PackageDependency (id));
		}

		public List<FrameworkAssemblyReference> FrameworkAssembliesList = 
			new List<FrameworkAssemblyReference> ();

		public IEnumerable<FrameworkAssemblyReference> FrameworkAssemblies {
			get { return FrameworkAssembliesList; }
		}

		public FakePackageRepository FakePackageRepository = new FakePackageRepository ();

		public IPackageRepository Repository {
			get { return FakePackageRepository; }
		}

		public bool HasDependencies { get; set; }

		public void AddFile (string fileName)
		{
			var file = new PhysicalPackageFile ();
			file.TargetPath = fileName.ToNativePath ();
			FilesList.Add (file);
		}

		public DateTime? LastUpdated { get; set; }

		public bool IsLatestVersion { get; set; }

		public Nullable<DateTimeOffset> Published { get; set; }

		public string ReleaseNotes { get; set; }

		public string Copyright { get; set; }

		public bool IsAbsoluteLatestVersion { get; set; }

		public bool Listed { get; set; }

		public IEnumerable<PackageDependencySet> DependencySets {
			get {
				return new PackageDependencySet[] {
					new PackageDependencySet (null, DependenciesList)
				};
			}
		}

		public List<FrameworkName> SupportedFrameworks = new List<FrameworkName> ();

		public FrameworkName AddSupportedFramework (string identifier)
		{
			var framework = new FrameworkName (identifier);
			SupportedFrameworks.Add (framework);
			return framework;
		}

		public IEnumerable<FrameworkName> GetSupportedFrameworks ()
		{
			return SupportedFrameworks;
		}

		List<PackageReferenceSet> FakePackageAssemblyReferences = 
			new List<PackageReferenceSet> ();

		public ICollection<PackageReferenceSet> PackageAssemblyReferences {
			get { return FakePackageAssemblyReferences; }
		}

		public void AddPackageReferences (params string[] names)
		{
			var frameworkName = new FrameworkName (".NET Framework, Version=4.0");
			var packageReferenceSet = new PackageReferenceSet (frameworkName, names);
			FakePackageAssemblyReferences.Add (packageReferenceSet);
		}

		public Version MinClientVersion { get; set; }

		public Uri GalleryUrl { get; set; }

		public bool DevelopmentDependency { get; set; }
	}
}