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 InvokingPropertiesAndMethodsBeforeInitializationThrows() { // Arrange var mockVpp = new Mock<VirtualPathProvider>().Object; var scope = new ScopeStorageDictionary(); var themesImpl = new ThemesImplementation(mockVpp, scope); // Act and Assert Assert.Throws<InvalidOperationException>(() => themesImpl.CurrentTheme = "Foo", @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws<InvalidOperationException>(() => { var x = themesImpl.CurrentTheme; }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws<InvalidOperationException>(() => { var x = themesImpl.AvailableThemes; }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws<InvalidOperationException>(() => { var x = themesImpl.DefaultTheme; }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws<InvalidOperationException>(() => { var x = themesImpl.GetResourcePath("baz"); }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws<InvalidOperationException>(() => { var x = themesImpl.GetResourcePath("baz", "some-file"); }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); }
public void InvokingPropertiesAndMethodsBeforeInitializationThrows() { // Arrange var mockVpp = new Mock <VirtualPathProvider>().Object; var scope = new ScopeStorageDictionary(); var themesImpl = new ThemesImplementation(mockVpp, scope); // Act and Assert Assert.Throws <InvalidOperationException>(() => themesImpl.CurrentTheme = "Foo", @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws <InvalidOperationException>(() => { var x = themesImpl.CurrentTheme; }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws <InvalidOperationException>(() => { var x = themesImpl.AvailableThemes; }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws <InvalidOperationException>(() => { var x = themesImpl.DefaultTheme; }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws <InvalidOperationException>(() => { var x = themesImpl.GetResourcePath("baz"); }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); Assert.Throws <InvalidOperationException>(() => { var x = themesImpl.GetResourcePath("baz", "some-file"); }, @"You must call the ""Themes.Initialize"" method before you call any other method of the ""Themes"" class."); }
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 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 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 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 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 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 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"); }