Ejemplo n.º 1
0
        public void AreTheSame()
        {
            var l1 = new SimpleDeltaStringList();
            var l2 = new SimpleDeltaStringList();

            Assert.Equal(l1, l2);
        }
Ejemplo n.º 2
0
        public void ShouldApplyEventsDeterministicallyStringList()
        {
            var list = new SimpleDeltaStringList();

            list.TestBar.Add("hello");
            list.TestBar.Add("world");
            list.TestBar.Add("bad");
            list.TestBar.Add("bad_index");
            list.TestBar[1] = "worlds";
            list.TestBar.Insert(1, "all");
            list.TestBar.Remove("bad");
            list.TestBar.RemoveAt(3);
            list.TestBar.Clear();
            list.TestBar.Add("hello");
            list.TestBar.Add("world");
            list.TestBar.Add("bad");
            list.TestBar.Add("bad_index");
            list.TestBar[1] = "worlds";
            list.TestBar.Insert(1, "all");
            list.TestBar.Remove("bad");
            list.TestBar.RemoveAt(3);

            var root    = list.PeekEvents();
            var newList = new SimpleDeltaStringList();

            newList.ApplyEvents(root);

            Assert.Equal(list, newList);
            Assert.Equal(3, newList.TestBar.Count);
            Assert.Equal("hello", newList.TestBar[0]);
            Assert.Equal("all", newList.TestBar[1]);
            Assert.Equal("worlds", newList.TestBar[2]);
        }
Ejemplo n.º 3
0
        public void ShouldGenerateAddEvent()
        {
            var list = new SimpleDeltaStringList();

            list.TestBar.Add("hello");

            Assert.Equal(1, list.TestBar.Count);

            var root = AssertGenerated(list);
            var e    = root.Events[0];

            Assert.Equal(ListAction.AddList, e.ListEvent.ListAction);
            AssertPath(e, new[] { 11 });
        }
Ejemplo n.º 4
0
        public void ShouldGenerateRemoveEvent()
        {
            var list = new SimpleDeltaStringList();

            list.TestBar.Add("hello");
            list.ClearEvents();             // throw away changes

            list.TestBar.Remove("hello");
            Assert.Equal(0, list.TestBar.Count);

            var root = AssertGenerated(list);
            var e    = root.Events[0];

            Assert.Equal(ListAction.RemoveList, e.ListEvent.ListAction);
            AssertPath(e, new[] { 11 });
        }
Ejemplo n.º 5
0
        public void ShouldGenerateInsertEvent()
        {
            var list = new SimpleDeltaStringList();

            list.TestBar.Add("hello");
            list.TestBar.Add("world");
            list.ClearEvents();             // throw away changes

            list.TestBar.Insert(1, "all");
            Assert.Equal(3, list.TestBar.Count);

            var root = AssertGenerated(list);
            var e    = root.Events[0];

            Assert.Equal(ListAction.InsertList, e.ListEvent.ListAction);
            AssertPath(e, new[] { 11 });
            Assert.Equal(1, e.ListEvent.Index);
        }