示例#1
0
        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"
                );
        }
示例#2
0
        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);
        }
示例#3
0
        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");
        }
示例#9
0
        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 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);
        }
示例#14
0
        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");
        }
示例#15
0
        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);
        }
示例#16
0
        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");
        }
示例#17
0
        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.");
        }
示例#18
0
        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);
        }
示例#19
0
        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");
        }
示例#20
0
        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);
        }
示例#21
0
        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);
        }
示例#22
0
        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");
        }
示例#23
0
        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);
        }
示例#24
0
        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");
        }