예제 #1
0
        public void Should_throw_When_css_syntax_error()
        {
            var mockFileReader     = CreateMockFileReader(GetThemeContent(KnownColor.Control, Color.Red) + "}");
            var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>();
            var loader             = new ThemeLoader(mockCssUrlResolver, mockFileReader);

            loader.Invoking(l => LoadTheme(l))
            .Should().Throw <ThemeException>()
            .Which.Message.Should().Contain("Error parsing CSS");
        }
예제 #2
0
        public void Should_throw_When_unknown_color_name()
        {
            var mockFileReader     = CreateMockFileReader(GetThemeContent("InvalidColorName", Color.Red));
            var mockCssUrlResolver = Substitute.For <IThemeCssUrlResolver>();
            var loader             = new ThemeLoader(mockCssUrlResolver, mockFileReader);

            loader.Invoking(l => LoadTheme(l))
            .Should().Throw <ThemeException>()
            .Which.Message.Should().Contain("InvalidColorName");
        }
예제 #3
0
        public void Should_throw_When_cyclic_css_imports()
        {
            var pathProvider = CreateMockPathProvider();
            var resolver     = new ThemeCssUrlResolver(pathProvider);

            string themePath     = Path.Combine(pathProvider.AppThemesDirectory, "theme.css");
            string baseThemePath = Path.Combine(pathProvider.AppThemesDirectory, "base.css");

            var mockFileReader = CreateMockFileReader(new Dictionary <string, string>
            {
                [baseThemePath] = "@import url(\"theme.css\");",
                [themePath]     = "@import url(\"base.css\");"
            });

            var loader = new ThemeLoader(resolver, mockFileReader);

            loader.Invoking(_ => _.LoadTheme(
                                themePath,
                                new ThemeId("theme", isBuiltin: true),
                                allowedClasses: ThemeVariations.None))
            .Should().Throw <ThemeException>()
            .Which.Message.Should().Contain("Cycling CSS import");
        }