예제 #1
0
        public void SourceMoveUp()
        {
            var sources = new SongSource[] {
                SongSource.Parse("Book / 1", song),
                SongSource.Parse("Book / 2", song),
                SongSource.Parse("Book / 3", song)
            };

            song.SetSources(sources);
            ClearUndoRedoStack();

            song.MoveSourceUp(sources[2]);
            Assert.Equal(3, song.Sources.Count);
            Assert.ReferenceEquals(sources[2], song.FirstSource);
            Assert.Equal(1, UndoStackSize);
            Undo();
            for (int i = 0; i < 3; i++)
            {
                Assert.Equal("Book", song.Sources[i].Songbook);
                Assert.Equal(i + 1, song.Sources[i].Number);
            }
            Redo();
            Assert.Equal(3, song.Sources.Count);
            Assert.ReferenceEquals(sources[2], song.FirstSource);
        }
예제 #2
0
        public void SourceSetUndoRedo()
        {
            song.SetSources(new SongSource[] { });
            this.ClearUndoRedoStack();
            Assert.Equal(1, song.Sources.Count);
            var sources = new SongSource[] {
                SongSource.Parse("Book / 1", song),
                SongSource.Parse("Book / 2", song),
                SongSource.Parse("Book / 3", song)
            };

            Assert.Equal(0, UndoStackSize);
            song.SetSources(sources);
            Assert.Equal(1, UndoStackSize);
            Undo();
            Assert.Equal(1, song.Sources.Count);
            Assert.Equal(String.Empty, song.FirstSource.ToString());
            Redo();
            Assert.Equal(3, song.Sources.Count);
            for (int i = 0; i < 3; i++)
            {
                Assert.Equal("Book", song.Sources[i].Songbook);
                Assert.Equal(i + 1, song.Sources[i].Number);
            }
        }
예제 #3
0
        public void SongSourceRemoveClean()
        {
            var weakRef = new WeakReference(song.FirstSource);

            song.IsUndoEnabled = false;
            song.SetSources(new SongSource[] { SongSource.Parse("Book / 1", song) });
            GC.Collect();
            Assert.False(weakRef.IsAlive);
        }
예제 #4
0
        public void SourceParse()
        {
            var source = SongSource.Parse("Book / 1", song);

            Assert.Equal("Book", source.Songbook);
            Assert.Equal(1, source.Number);

            // parsing a source should not influence the undo stack
            Assert.Equal(0, UndoStackSize);
            Assert.Equal(0, RedoStackSize);
        }
예제 #5
0
        public void SourceSetSingle()
        {
            song.SetSources(new SongSource[] { });
            Assert.Equal(1, song.Sources.Count);
            Assert.NotNull(song.FirstSource);
            var source = SongSource.Parse("Book / 1", song);

            song.SetSources(new SongSource[] { source });
            Assert.Equal(1, song.Sources.Count);
            Assert.Equal("Book", song.Sources[0].Songbook);
            Assert.Equal(1, song.Sources[0].Number);
            Assert.ReferenceEquals(song.Sources[0], song.FirstSource);
        }
예제 #6
0
        public void SourceSetMultiple()
        {
            song.SetSources(new SongSource[] { });
            Assert.Equal(1, song.Sources.Count);
            var sources = new SongSource[] {
                SongSource.Parse("Book / 1", song),
                SongSource.Parse("Book / 2", song),
                SongSource.Parse("Book / 3", song)
            };

            song.SetSources(sources);
            Assert.Equal(3, song.Sources.Count);
            for (int i = 0; i < 3; i++)
            {
                Assert.Equal("Book", song.Sources[i].Songbook);
                Assert.Equal(i + 1, song.Sources[i].Number);
            }
        }
예제 #7
0
        public void SourceRemoveUndoRedo()
        {
            var sources = new SongSource[] {
                SongSource.Parse("Book / 1", song),
                SongSource.Parse("Book / 2", song),
                SongSource.Parse("Book / 3", song)
            };

            song.SetSources(sources);
            ClearUndoRedoStack();
            song.RemoveSource(song.FirstSource);
            song.RemoveSource(song.FirstSource);
            Assert.Equal(1, song.Sources.Count);
            Undo();
            Undo();
            for (int i = 0; i < 3; i++)
            {
                Assert.Equal("Book", song.Sources[i].Songbook);
                Assert.Equal(i + 1, song.Sources[i].Number);
            }
            Redo();
            Redo();
            Assert.Equal(1, song.Sources.Count);
        }