|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Apache License, Version 2.0. |
3 | 3 |
|
| 4 | +using System; |
4 | 5 | using SixLabors.ImageSharp.Web.Caching; |
5 | 6 | using Xunit; |
6 | 7 |
|
@@ -31,21 +32,36 @@ public void FilePathMatchesReference(string key, int cacheFolderDepth, string ex |
31 | 32 | [InlineData("cacheFolder", null, "/Users/WebRoot", null, "/Users/WebRoot/cacheFolder/")] |
32 | 33 | [InlineData("cacheFolder", "../Temp", null, "/Users/this/a/root", "/Users/this/a/Temp/cacheFolder/")] |
33 | 34 | #elif OS_WINDOWS |
34 | | - [InlineData("cacheFolder", "C:/Temp", null, null, "C:/Temp\\cacheFolder\\")] |
35 | | - [InlineData("cacheFolder", null, "C:/WebRoot", null, "C:/WebRoot\\cacheFolder\\")] |
36 | | - [InlineData("cacheFolder", "../Temp", null, "C:/this/a/root", "C:\\this\\a\\Temp\\cacheFolder\\")] |
| 35 | + [InlineData("cacheFolder", "C:\\Temp", null, null, "C:\\Temp\\cacheFolder\\")] |
| 36 | + [InlineData("cacheFolder", null, "C:\\WebRoot", null, "C:\\WebRoot\\cacheFolder\\")] |
| 37 | + [InlineData("cacheFolder", "..\\Temp", null, "C:\\this\\a\\root", "C:\\this\\a\\Temp\\cacheFolder\\")] |
37 | 38 | #endif |
38 | | - public void CacheRootFromOptions(string cacheFolder, string cacheRoot, string webRootPath, string contentRootPath, string expected) |
| 39 | + public void GetCacheRoot(string cacheFolder, string cacheRootPath, string webRootPath, string contentRootPath, string expected) |
39 | 40 | { |
40 | 41 | var cacheOptions = new PhysicalFileSystemCacheOptions |
41 | 42 | { |
42 | 43 | CacheFolder = cacheFolder, |
43 | | - CacheRootPath = cacheRoot |
| 44 | + CacheRootPath = cacheRootPath |
44 | 45 | }; |
45 | 46 |
|
46 | | - string cacheRootResult = PhysicalFileSystemCache.GetCacheRoot(cacheOptions, webRootPath, contentRootPath); |
| 47 | + string actual = PhysicalFileSystemCache.GetCacheRoot(cacheOptions, webRootPath, contentRootPath); |
47 | 48 |
|
48 | | - Assert.Equal(expected, cacheRootResult); |
| 49 | + Assert.Equal(expected, actual); |
| 50 | + } |
| 51 | + |
| 52 | + [Theory] |
| 53 | + [InlineData("cacheFolder", null, null, "C:\\root\\")] |
| 54 | + [InlineData("cacheFolder", "", null, "C:\\root\\")] |
| 55 | + [InlineData("cacheFolder", null, "", "C:\\root\\")] |
| 56 | + public void GetCacheRootThrows(string cacheFolder, string cacheRootPath, string webRootPath, string contentRootPath) |
| 57 | + { |
| 58 | + var cacheOptions = new PhysicalFileSystemCacheOptions |
| 59 | + { |
| 60 | + CacheFolder = cacheFolder, |
| 61 | + CacheRootPath = cacheRootPath |
| 62 | + }; |
| 63 | + |
| 64 | + Assert.Throws<InvalidOperationException>(() => PhysicalFileSystemCache.GetCacheRoot(cacheOptions, webRootPath, contentRootPath)); |
49 | 65 | } |
50 | 66 | } |
51 | 67 | } |
0 commit comments