Exemplo n.º 1
0
        public void TestLoad()
        {
            var theme = new Theme();
            theme.LoadFromPath(_themePath);

            // Assert the loaded theme has expected values
            foreach (var field in _themeDict) {
                Assert.That(theme.Config[field.Key], Is.EqualTo(field.Value));
            }
        }
Exemplo n.º 2
0
        public void TestDelete()
        {
            // copy test theme
            var copyPath = Path.GetTempFileName();
            File.Copy(_themePath, copyPath, true);

            // load the copy
            var theme = new Theme();
            theme.LoadFromPath(copyPath);

            // delete
            theme.Delete();

            // assert the file does not exist
            Assert.That(File.Exists(copyPath), Is.False);
        }
Exemplo n.º 3
0
        public void TestLoadParseException()
        {
            // create new file
            var corruptThemePath = Path.GetTempFileName();

            // load the test theme file, and write a corrupt version
            var contents = File.ReadAllText(_themePath);
            contents = contents.Replace("{", "!!!");
            File.WriteAllText(corruptThemePath, contents);

            // assert that loading causes exception
            Assert.That(() =>
            {
                var theme = new Theme();
                theme.LoadFromPath(corruptThemePath);
            }, Throws.Exception.TypeOf<JsonReaderException>());
        }
Exemplo n.º 4
0
        public void TestSave()
        {
            // load test theme
            var theme = new Theme();
            theme.LoadFromPath(_themePath);

            // export to another path
            var themeSavePath = Path.GetTempFileName();
            theme.Save(themeSavePath);

            // load the export
            var exportedTheme = new Theme();
            exportedTheme.LoadFromPath(themeSavePath);

            // Assert the loaded theme has expected values
            foreach (var field in _themeDict) {
                Assert.That(theme.Config[field.Key], Is.EqualTo(field.Value));
            }
        }
Exemplo n.º 5
0
        public void TestResourceDictionary()
        {
            var theme = new Theme();
            theme.LoadFromPath(_themePath);

            var resourceDictionary = theme.ToResourceDictionary();
            // test the resource dictionary for correctness by comparing each color
            foreach (var colorKey in _colorKeys) {
                var actualColor = ((SolidColorBrush) resourceDictionary[colorKey]).Color;
                var expectedColor =
                    ((SolidColorBrush) new BrushConverter().ConvertFromString(_themeDict[colorKey])).Color;
                Assert.That(actualColor, Is.EqualTo(expectedColor));
            }
        }
Exemplo n.º 6
0
 public void TestLoadWithBadPath()
 {
     var theme = new Theme();
     var randomPath = Path.Combine("c:\\", Path.GetRandomFileName());
     Assert.Throws<FileNotFoundException>(() => theme.LoadFromPath(randomPath));
 }