-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from johanbenschop/feature/tree-icons
Add tree icons and icon rotation features with miscellaneous changes
- Loading branch information
Showing
73 changed files
with
12,658 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-8.93 KB
(93%)
src/Geta.Epi.FontThumbnail.Tests/App_Data/fonts/fa-brands-400.ttf
Binary file not shown.
Binary file modified
BIN
-5.85 KB
(85%)
src/Geta.Epi.FontThumbnail.Tests/App_Data/fonts/fa-regular-400.ttf
Binary file not shown.
Binary file modified
BIN
-22 KB
(89%)
src/Geta.Epi.FontThumbnail.Tests/App_Data/fonts/fa-solid-900.ttf
Binary file not shown.
126 changes: 126 additions & 0 deletions
126
src/Geta.Epi.FontThumbnail.Tests/AssemblyResourceProviderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using EPiServer.ServiceLocation; | ||
using EPiServer.Web; | ||
using EPiServer.Web.Internal; | ||
using Geta.Epi.FontThumbnail.ResourceProvider; | ||
using Moq; | ||
using Xunit; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests | ||
{ | ||
public class AssemblyResourceProviderFixture | ||
{ | ||
public AssemblyResourceProviderFixture() | ||
{ | ||
var virtualPathResolver = new DefaultVirtualPathResolver(WebHostingEnvironment.Instance); | ||
var mockServiceLocator = new Mock<IServiceLocator>(); | ||
mockServiceLocator.Setup(i => i.GetInstance<IVirtualPathResolver>()).Returns(virtualPathResolver); | ||
|
||
ServiceLocator.SetLocator(mockServiceLocator.Object); | ||
|
||
EPiServer.Shell.Configuration.EPiServerShellSection.GetSection().ProtectedModules.RootPath = "~/EPiServer/"; | ||
} | ||
} | ||
|
||
public class AssemblyResourceProviderTests : IClassFixture<AssemblyResourceProviderFixture> | ||
{ | ||
[Fact] | ||
public void GetCacheKey_ShouldReturnNull() | ||
{ | ||
// Arrange | ||
var provider = new AssemblyResourceProvider(); | ||
const string virtualPath = "~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/css/all.min.css"; | ||
|
||
// Act | ||
var result = provider.GetCacheKey(virtualPath); | ||
|
||
// Assert | ||
Assert.Null(result); | ||
} | ||
|
||
[Fact] | ||
public void GetCacheDependency_ShouldNeverExpire() | ||
{ | ||
// Arrange | ||
var provider = new AssemblyResourceProvider(); | ||
const string virtualPath = "~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/fa5/css/all.min.css"; | ||
|
||
// Act | ||
var result = provider.GetCacheDependency(virtualPath, new string[0], DateTime.Now); | ||
|
||
// Assert | ||
Assert.IsType<NeverExpiresCacheCacheDependency>(result); | ||
Assert.False(result.HasChanged); | ||
Assert.Equal(new DateTime(), result.UtcLastModified); | ||
} | ||
|
||
[Fact] | ||
public void GetFileHash_ShouldWork() | ||
{ | ||
// Arrange | ||
var provider = new AssemblyResourceProvider(); | ||
|
||
// Act | ||
var result = provider.GetFileHash("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/fa5/css/all.min.css", new string[0]); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.Equal("b03f3a2c".Length, result.Length); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GetFilesInClientResourcesFolder))] | ||
public void FilesInClientResourcesFolder_ShouldExist(string path) | ||
{ | ||
// Arrange | ||
var provider = new AssemblyResourceProvider(); | ||
|
||
// Act | ||
var result = provider.FileExists("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources" + path); | ||
|
||
// Assert | ||
Assert.True(result); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(GetFilesInClientResourcesFolder))] | ||
public void FilesInClientResourcesFolder_ShouldLoad(string path) | ||
{ | ||
// Arrange | ||
var provider = new AssemblyResourceProvider(); | ||
|
||
// Act | ||
var result = provider.GetFile("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources" + path); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
} | ||
|
||
[Theory] | ||
[InlineData("~/this-file-should-not-exist.ttf")] | ||
[InlineData("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/nor-this-file.woff2")] | ||
[InlineData("~/EPiServer/Geta.Epi.FontThumbnail/ClientResources/webfonts/and-not-this-file-too.woff2")] | ||
public void FilesNotInClientResourcesFolder_ShouldNotExist(string path) | ||
{ | ||
// Arrange | ||
var provider = new AssemblyResourceProvider(); | ||
|
||
// Act | ||
var result = provider.FileExists(path); | ||
|
||
// Assert | ||
Assert.False(result); | ||
} | ||
|
||
public static IEnumerable<object[]> GetFilesInClientResourcesFolder() | ||
{ | ||
const string basePath = "../../../../Geta.Epi.FontThumbnail/ClientResources"; | ||
var allFiles = Directory.GetFiles(basePath, "*.*", SearchOption.AllDirectories); | ||
|
||
foreach (var file in allFiles) | ||
yield return new[] {file.Substring(basePath.Length).Replace("\\", "/")}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/Geta.Epi.FontThumbnail.Tests/Models/ImageDataWithOnlyThumbnailIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Image)] | ||
public class ImageDataWithOnlyThumbnailIcon : ImageData | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Geta.Epi.FontThumbnail.Tests/Models/MediaDataWithOnlyThumbnailIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Images)] | ||
public class MediaDataWithOnlyThumbnailIcon : MediaData | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithOnlyThumbnailIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Road)] | ||
public class PageWithOnlyThumbnailIcon : PageData | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithOnlyTreeIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[TreeIcon(FontAwesome5Solid.Road)] | ||
public class PageWithOnlyTreeIcon : PageData | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithOnlyTreeIconWithoutIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[TreeIcon] | ||
public class PageWithOnlyTreeIconWithoutIcon : PageData | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithThumbnailIconAndDifferentTreeIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Clock)] | ||
[TreeIcon(FontAwesome5Regular.Clock)] | ||
public class PageWithThumbnailIconAndDifferentTreeIcon : PageData | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithThumbnailIconAndDifferentTreeIconRotation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Wind, Rotations.Rotate180)] | ||
[TreeIcon(FontAwesome5Regular.Flag, Rotations.Rotate90)] | ||
public class PageWithThumbnailIconAndDifferentTreeIconRotation : PageData | ||
{ | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithThumbnailIconAndInheritedTreeIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.BoxOpen)] | ||
public class PageWithThumbnailIconAndInheritedTreeIcon : PageWithThumbnailIconAndDifferentTreeIcon | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithThumbnailIconAndRotation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Cookie, Rotations.Rotate180)] | ||
public class PageWithThumbnailIconAndRotation : PageData | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithThumbnailIconAndTreeIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Anchor)] | ||
[TreeIcon] | ||
public class PageWithThumbnailIconAndTreeIcon : PageData | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithThumbnailIconAndTreeIconOnIgnore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[ThumbnailIcon(FontAwesome5Solid.Anchor)] | ||
[TreeIcon(Ignore = true)] | ||
public class PageWithThumbnailIconAndTreeIconOnIgnore : PageData | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithTreeIconAmdRotation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
[TreeIcon(FontAwesome5Solid.Water, Rotations.Rotate90)] | ||
public class PageWithTreeIconAmdRotation : PageData | ||
{ | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Geta.Epi.FontThumbnail.Tests/Models/PageWithoutThumbnailIcon.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using EPiServer.Core; | ||
|
||
namespace Geta.Epi.FontThumbnail.Tests.Models | ||
{ | ||
public class PageWithoutThumbnailIcon : PageData | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.