public void GetResourcePathThrowsIfFileNameIsNullOrEmpty() { // Arrange var themesImpl = new ThemesImplementation( scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider( "themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile", "wp7.css") ) ); themesImpl.Initialize("themes", "default"); // Act and Assert Assert.ThrowsArgumentNullOrEmptyString( () => themesImpl.GetResourcePath(folder: String.Empty, fileName: null), "fileName" ); Assert.ThrowsArgumentNullOrEmptyString( () => themesImpl.GetResourcePath(folder: String.Empty, fileName: String.Empty), "fileName" ); }
public void GetResourcePathReturnsNullIfDirectoryDoesNotExist() { // Arrange var themesImpl = new ThemesImplementation( scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider( "themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile\styles", "wp7.css"), new Dir(@"default\styles", "main.css") ) ); themesImpl.Initialize("themes", "default"); // Act themesImpl.CurrentTheme = "mobile"; var themePath = themesImpl.GetResourcePath( folder: "does-not-exist", fileName: "main.css" ); // Assert Assert.Null(themePath); }
public void GetResourcePathReturnsNullIfItemNotFoundInCurrentAndDefaultThemeDirectories() { // Arrange var themesImpl = new ThemesImplementation( scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider( "themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile\styles", "wp7.css"), new Dir(@"default\styles", "main.css") ) ); themesImpl.Initialize("themes", "default"); // Act themesImpl.CurrentTheme = "mobile"; var themePath = themesImpl.GetResourcePath( folder: "styles", fileName: "awesome-blinking-text.css" ); // Assert Assert.Null(themePath); }
public void GetResourcePathThrowsIfCurrentDirectoryIsNull() { // Arrange var themesImpl = new ThemesImplementation(scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider("themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile", "wp7.css"))); themesImpl.Initialize("themes", "default"); // Act and Assert Assert.ThrowsArgumentNull(() => themesImpl.GetResourcePath(folder: null, fileName: "wp7.css"), "folder"); }
public void ThemesImplThrowsIfCurrentThemeIsInvalid() { // Arrange var defaultTheme = "default-theme"; var themeDirectory = "theme-directory"; var themesImpl = new ThemesImplementation(GetVirtualPathProvider(themeDirectory, new Dir(defaultTheme), new Dir("not-a-random-value")), new ScopeStorageDictionary()); themesImpl.Initialize(themeDirectory, defaultTheme); // Act and Assert Assert.ThrowsArgument(() => themesImpl.CurrentTheme = "random-value", "value", "Unknown theme 'random-value'. Ensure that a directory labeled 'random-value' exists under the theme directory."); }
public void ThemesImplUsesDefaultThemeWhenNoCurrentThemeIsSpecified() { // Arrange var defaultTheme = "default-theme"; var themeDirectory = "theme-directory"; var scope = new ScopeStorageDictionary(); var themesImpl = new ThemesImplementation(GetVirtualPathProvider(themeDirectory, new Dir(defaultTheme)), scope); themesImpl.Initialize(themeDirectory, defaultTheme); // Act and Assert // CurrentTheme falls back to default theme when null Assert.Equal(themesImpl.CurrentTheme, defaultTheme); }
public void InitializeThrowsIfDefaultThemeDirectoryDoesNotExist() { // Arrange var defaultTheme = "default-theme"; var themeDirectory = "theme-directory"; var scope = new ScopeStorageDictionary(); var themesImpl = new ThemesImplementation(GetVirtualPathProvider(themeDirectory, new Dir("not-default-theme")), scope); // Act And Assert Assert.ThrowsArgument( () => themesImpl.Initialize(themeDirectory: themeDirectory, defaultTheme: defaultTheme), "defaultTheme", "Unknown theme 'default-theme'. Ensure that a directory labeled 'default-theme' exists under the theme directory."); }
public void GetResourcePathReturnsItemFromDefaultThemeDirectoryIfNotFoundInCurrentThemeDirectory() { // Arrange var themesImpl = new ThemesImplementation(scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider("themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile\styles", "wp7.css"), new Dir(@"default\styles", "main.css"))); themesImpl.Initialize("themes", "default"); // Act themesImpl.CurrentTheme = "mobile"; var themePath = themesImpl.GetResourcePath(folder: "styles", fileName: "main.css"); // Assert Assert.Equal(themePath, @"themes/default/styles/main.css"); }
public void GetResourcePathReturnsItemFromThemeRootIfAvailable() { // Arrange var themesImpl = new ThemesImplementation(scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider("themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile", "wp7.css"))); themesImpl.Initialize("themes", "default"); // Act themesImpl.CurrentTheme = "mobile"; var themePath = themesImpl.GetResourcePath(fileName: "wp7.css"); // Assert Assert.Equal(themePath, @"themes/mobile/wp7.css"); }
public void AvaliableThemesReturnsTopLevelDirectoriesUnderThemeDirectory() { // Arrange var themesImpl = new ThemesImplementation(scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider("themes", new Dir("default"), new Dir("mobile"), new Dir("rotary-phone"))); // Act themesImpl.Initialize("themes", "default"); var themes = themesImpl.AvailableThemes; // Assert Assert.Equal(3, themes.Count); Assert.Equal(themes[0], "default"); Assert.Equal(themes[1], "mobile"); Assert.Equal(themes[2], "rotary-phone"); }
public void ThemesImplUsesScopeStorageToStoreCurrentTheme() { // Arrange var defaultTheme = "default-theme"; var themeDirectory = "theme-directory"; var currentThemeDir = "custom-theme-dir"; var scope = new ScopeStorageDictionary(); var themesImpl = new ThemesImplementation(GetVirtualPathProvider(themeDirectory, new Dir(defaultTheme), new Dir("custom-theme-dir")), scope); // Act themesImpl.Initialize(themeDirectory, defaultTheme); themesImpl.CurrentTheme = currentThemeDir; // Assert Assert.Equal(scope[ThemesImplementation.CurrentThemeKey], currentThemeDir); }
public void ThemesImplUsesScopeStorageToStoreProperties() { // Arrange var defaultTheme = "default-theme"; var themeDirectory = "theme-directory"; var scope = new ScopeStorageDictionary(); var themesImpl = new ThemesImplementation(GetVirtualPathProvider(themeDirectory, new Dir(defaultTheme)), scope); // Act themesImpl.Initialize(themeDirectory: themeDirectory, defaultTheme: defaultTheme); // Ensure Theme use scope storage to store properties Assert.Equal(scope[ThemesImplementation.ThemesInitializedKey], true); Assert.Equal(scope[ThemesImplementation.ThemeDirectoryKey], themeDirectory); Assert.Equal(scope[ThemesImplementation.DefaultThemeKey], defaultTheme); }
public void GetResourcePathReturnsNullIfDirectoryDoesNotExist() { // Arrange var themesImpl = new ThemesImplementation(scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider("themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile\styles", "wp7.css"), new Dir(@"default\styles", "main.css"))); themesImpl.Initialize("themes", "default"); // Act themesImpl.CurrentTheme = "mobile"; var themePath = themesImpl.GetResourcePath(folder: "does-not-exist", fileName: "main.css"); // Assert Assert.Null(themePath); }
public void GetResourcePathReturnsNullIfItemNotFoundInCurrentAndDefaultThemeDirectories() { // Arrange var themesImpl = new ThemesImplementation(scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider("themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile\styles", "wp7.css"), new Dir(@"default\styles", "main.css"))); themesImpl.Initialize("themes", "default"); // Act themesImpl.CurrentTheme = "mobile"; var themePath = themesImpl.GetResourcePath(folder: "styles", fileName: "awesome-blinking-text.css"); // Assert Assert.Null(themePath); }
public void GetResourcePathThrowsIfFileNameIsNullOrEmpty() { // Arrange var themesImpl = new ThemesImplementation(scopeStorage: new ScopeStorageDictionary(), vpp: GetVirtualPathProvider("themes", new Dir("default"), new Dir("mobile"), new Dir(@"mobile", "wp7.css"))); themesImpl.Initialize("themes", "default"); // Act and Assert Assert.ThrowsArgumentNullOrEmptyString(() => themesImpl.GetResourcePath(folder: String.Empty, fileName: null), "fileName"); Assert.ThrowsArgumentNullOrEmptyString(() => themesImpl.GetResourcePath(folder: String.Empty, fileName: String.Empty), "fileName"); }