8 changed files with 125 additions and 10 deletions
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public static class IPackageExtensions |
||||
{ |
||||
/// <summary>
|
||||
/// Returns description if summary is missing.
|
||||
/// </summary>
|
||||
public static string SummaryOrDescription(this IPackage package) |
||||
{ |
||||
if (String.IsNullOrEmpty(package.Summary)) |
||||
return package.Description; |
||||
return package.Summary; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class PackageLicenseViewModel : ViewModelBase<PackageLicenseViewModel> |
||||
{ |
||||
IPackage package; |
||||
|
||||
public PackageLicenseViewModel(IPackage package) |
||||
{ |
||||
this.package = package; |
||||
} |
||||
|
||||
public string Id { |
||||
get { return package.Id; } |
||||
} |
||||
|
||||
public string Summary { |
||||
get { return package.SummaryOrDescription(); } |
||||
} |
||||
|
||||
public Uri LicenseUrl { |
||||
get { return package.LicenseUrl; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// 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.PackageManagement; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.PackageManagement.Design; |
||||
using NuGet; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PackageManagement.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class IPackageExtensionsTests |
||||
{ |
||||
FakePackage package; |
||||
|
||||
void CreatePackageWithSummary(string summary) |
||||
{ |
||||
package = new FakePackage() { Summary = summary }; |
||||
} |
||||
|
||||
[Test] |
||||
public void SummaryOrDescription_PackageHasSummary_ReturnsSummary() |
||||
{ |
||||
CreatePackageWithSummary("summary"); |
||||
|
||||
string result = package.SummaryOrDescription(); |
||||
|
||||
Assert.AreEqual("summary", result); |
||||
} |
||||
|
||||
[Test] |
||||
public void SummaryOrDescription_PackageHasDescriptionButNullSummary_ReturnsDescription() |
||||
{ |
||||
CreatePackageWithSummary(null); |
||||
package.Description = "description"; |
||||
|
||||
string result = package.SummaryOrDescription(); |
||||
|
||||
Assert.AreEqual("description", result); |
||||
} |
||||
|
||||
[Test] |
||||
public void SummaryOrDescription_PackageHasDescriptionButEmptySummary_ReturnsDescription() |
||||
{ |
||||
CreatePackageWithSummary(String.Empty); |
||||
package.Description = "description"; |
||||
|
||||
string result = package.SummaryOrDescription(); |
||||
|
||||
Assert.AreEqual("description", result); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue