Exemplo n.º 1
0
        public void AddEntry_OrderIsSet()
        {
            var palette = new ColorPalette();
            var entry1  = palette.AddEntry();
            var entry2  = palette.AddEntry();

            Assert.That(palette.GetEntryOrder(entry1.Id), Is.Zero);
            Assert.That(palette.GetEntryOrder(entry2.Id), Is.EqualTo(1));
        }
Exemplo n.º 2
0
        public void RemoveEntry_Reordered()
        {
            var palette = new ColorPalette();
            var entry1  = palette.AddEntry();
            var entry2  = palette.AddEntry();
            var entry3  = palette.AddEntry();

            Assert.That(palette.GetEntryOrder(entry1.Id), Is.EqualTo(0));
            Assert.That(palette.GetEntryOrder(entry2.Id), Is.EqualTo(1));
            Assert.That(palette.GetEntryOrder(entry3.Id), Is.EqualTo(2));

            palette.RemoveEntry(entry2.Id);

            Assert.That(palette.GetEntryOrder(entry1.Id), Is.EqualTo(0));
            Assert.That(palette.GetEntryOrder(entry3.Id), Is.EqualTo(1));
        }
Exemplo n.º 3
0
        public void AddEntry_ActiveValueIsAdded()
        {
            var palette = new ColorPalette();
            var entry   = palette.AddEntry();

            Assert.That(palette.TryGetActiveValue(entry.Id, out _), Is.True);
        }
Exemplo n.º 4
0
        public void AddEntry_EntryIsAdded()
        {
            var palette = new ColorPalette();

            Assert.That(palette.Entries.Count, Is.Zero);
            palette.AddEntry();
            Assert.That(palette.Entries.Count, Is.EqualTo(1));
        }
Exemplo n.º 5
0
        public void RemoveEntry_EntryRemoved()
        {
            var palette = new ColorPalette();
            var entry   = palette.AddEntry();

            palette.RemoveEntry(entry.Id);

            Assert.That(palette.Entries.Count, Is.Zero);
        }
Exemplo n.º 6
0
        public void AddEntry_AddedEntryHasValueForActiveTheme()
        {
            var palette     = new ColorPalette();
            var activeTheme = palette.ActiveTheme.Value;
            var entry       = palette.AddEntry();

            Assert.That(entry.Values.Count, Is.EqualTo(1));
            Assert.That(entry.Values.ContainsKey(activeTheme.Id), Is.True);
        }
Exemplo n.º 7
0
        public void AddTheme_EntryValueIsAdded()
        {
            var palette = new ColorPalette();
            var entry   = palette.AddEntry();
            var theme   = palette.AddTheme();

            Assert.That(entry.Values.Count, Is.EqualTo(2));
            Assert.That(entry.Values.ContainsKey(theme.Id), Is.True);
        }
Exemplo n.º 8
0
        public void RemoveTheme_RemoveEntryValues()
        {
            var palette = new ColorPalette();
            var entry   = palette.AddEntry();
            var theme   = palette.AddTheme();

            Assert.That(entry.TryGetValue(theme.Id, out _), Is.True);

            palette.RemoveTheme(theme.Id);

            Assert.That(entry.TryGetValue(theme.Id, out _), Is.False);
        }
Exemplo n.º 9
0
        public void ActiveValue_CanObserve()
        {
            var palette    = new ColorPalette();
            var entry      = palette.AddEntry();
            var value      = palette.GetActiveValue(entry.Id);
            var color      = Color.black;
            var disposable = value.Subscribe(x => color = x);

            entry.Values.First().Value.Value = Color.cyan;
            Assert.That(color, Is.EqualTo(Color.cyan));
            disposable.Dispose();
        }
Exemplo n.º 10
0
        public void RestoreTheme_AddEntryAfterRemove_NewEntryHasValueForRestoredTheme()
        {
            var palette = new ColorPalette();
            var theme   = palette.AddTheme();

            palette.RemoveTheme(theme.Id);
            var entry = palette.AddEntry();

            Assert.That(entry.Values.ContainsKey(theme.Id), Is.False);

            palette.RestoreTheme(theme.Id);

            Assert.That(entry.Values.ContainsKey(theme.Id), Is.True);
        }
Exemplo n.º 11
0
        public void RestoreEntry_EntryIsRestored()
        {
            var palette = new ColorPalette();
            var entry   = palette.AddEntry();

            palette.RemoveEntry(entry.Id);
            var value = entry.Values.First();

            Assert.That(palette.Entries.Count, Is.Zero);

            var restoredEntry = palette.RestoreEntry(entry.Id);
            var restoredValue = restoredEntry.Values.First();

            Assert.That(palette.Entries.Count, Is.EqualTo(1));
            Assert.That(value.Key, Is.EqualTo(restoredValue.Key));
            Assert.That(value.Value.Value, Is.EqualTo(restoredValue.Value.Value));
        }
Exemplo n.º 12
0
        public void RestoreTheme_RemoveEntryAfterRemove_NoEntryIsCreated()
        {
            var palette = new ColorPalette();
            var theme   = palette.AddTheme();
            var entry   = palette.AddEntry();

            palette.RemoveTheme(theme.Id);

            Assert.That(palette.HasEntry(entry.Id), Is.True);

            palette.RemoveEntry(entry.Id);

            Assert.That(palette.HasEntry(entry.Id), Is.False);

            palette.RestoreTheme(theme.Id);

            Assert.That(palette.HasEntry(entry.Id), Is.False);
        }
Exemplo n.º 13
0
        public void RestoreEntry_AddThemeAfterRemove_NewEntryHasValueForRestoredTheme()
        {
            var palette = new ColorPalette();
            var entry   = palette.AddEntry();

            Assert.That(palette.Entries.Count, Is.EqualTo(1));
            Assert.That(entry.Values.Count, Is.EqualTo(1));

            palette.RemoveEntry(entry.Id);

            Assert.That(palette.Entries.Count, Is.EqualTo(0));

            var theme = palette.AddTheme();

            var restoredEntry = palette.RestoreEntry(entry.Id);

            Assert.That(palette.Entries.Count, Is.EqualTo(1));
            Assert.That(restoredEntry.Values.Count, Is.EqualTo(2));
            Assert.That(restoredEntry.Values.ContainsKey(theme.Id), Is.True);
        }
Exemplo n.º 14
0
        public void RestoreEntry_RemoveThemeAfterRemove_NoValueIsCreated()
        {
            var palette = new ColorPalette();
            var entry   = palette.AddEntry();
            var theme   = palette.AddTheme();

            Assert.That(palette.Entries.Count, Is.EqualTo(1));
            Assert.That(entry.Values.Count, Is.EqualTo(2));

            palette.RemoveEntry(entry.Id);

            Assert.That(palette.Entries.Count, Is.EqualTo(0));

            palette.RemoveTheme(theme.Id);

            var restoredEntry = palette.RestoreEntry(entry.Id);

            Assert.That(palette.Entries.Count, Is.EqualTo(1));
            Assert.That(restoredEntry.Values.Count, Is.EqualTo(1));
            Assert.That(restoredEntry.Values.ContainsKey(theme.Id), Is.False);
        }