Пример #1
0
        public void Test_Snapshot_Restore_Returns_Without_ModifiedList()
        {
            var list = new List <int> {
                1, 2, 3
            };

            var sp = new SnapShot(list);

            list.Add(4);

            var restoreList = sp.Restore();

            Assert.IsNotNull(restoreList);
            Assert.AreNotEqual(list.Count, restoreList.Count);
        }
Пример #2
0
        public void Test_Snapshot_Restore_Returns_Not_ModifiedList()
        {
            List <int> list = new List <int> {
                1, 2, 3
            };

            SnapShot sp = new SnapShot(list);

            list[0] = 10;

            var restoreList = sp.Restore();

            Assert.IsNotNull(restoreList);
            Assert.AreNotEqual(list[0], restoreList.ToList()[0]);
        }
Пример #3
0
        private static void Main()
        {
            var list = new List <int> {
                1, 2, 3
            };

            var sp = new SnapShot(list);

            list.Add(4);

            var restoreList = sp.Restore();

            //restoreList is IReadOnlyCollection, so we can not add to the ReadOnlyCollection

            Console.WriteLine(string.Join(",", restoreList));
            Console.ReadLine();
        }