11// Copyright (c) Six Labors.
22// Licensed under the Apache License, Version 2.0.
33
4+ using System . IO ;
45using SixLabors . ImageSharp . Web . Caching ;
56using Xunit ;
67
@@ -19,5 +20,30 @@ public void FilePathMatchesReference()
1920
2021 Assert . Equal ( expected , actual ) ;
2122 }
23+
24+ [ Theory ]
25+ #if Linux
26+ [ InlineData ( "cacheFolder" , "/Users/username" , null , null , "/Users/username/cacheFolder" ) ]
27+ [ InlineData ( "cacheFolder" , null , "/Users/WebRoot" , null , "/Users/WebRoot/cacheFolder" ) ]
28+ [ InlineData ( "cacheFolder" , "../Temp" , null , "/Users/this/a/root" , "/Users/this/a/Temp/cacheFolder" ) ]
29+ #elif OSX
30+ [ InlineData ( "cacheFolder" , "/Users/username" , null , null , "/Users/username/cacheFolder" ) ]
31+ [ InlineData ( "cacheFolder" , null , "/Users/WebRoot" , null , "/Users/WebRoot/cacheFolder" ) ]
32+ [ InlineData ( "cacheFolder" , "../Temp" , null , "/Users/this/a/root" , "/Users/this/a/Temp/cacheFolder" ) ]
33+ #elif 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" ) ]
37+ #endif
38+ public void CacheRootFromOptions ( string cacheFolder , string cacheRoot , string webRootPath , string contentRootPath , string expected )
39+ {
40+ var cacheOptions = new PhysicalFileSystemCacheOptions ( ) ;
41+ cacheOptions . CacheFolder = cacheFolder ;
42+ cacheOptions . CacheRoot = cacheRoot ;
43+
44+ var cacheRootResult = PhysicalFileSystemCache . GetCacheRoot ( cacheOptions , webRootPath , contentRootPath ) ;
45+
46+ Assert . Equal ( expected , cacheRootResult ) ;
47+ }
2248 }
2349}
0 commit comments