Example #1
0
        public void Blb2Loc_WhereOnly()
        {
            var source = new TestList();
            var synced = source.ToSyncList(c => c.Id > 100);

            Assert.AreEqual(3, synced.Count);
        }
Example #2
0
        public void Blb2Loc_RemoveOriginal()
        {
            var source = new TestList();
            var query  = from r in source
                         where r.Id > 100
                         select r;
            var synced = source.ToSyncList(query);
            int count  = 0;

            foreach (var item in synced)
            {
                count++;
            }
            Assert.AreEqual(3, count, "Calculated count wrong (br)");
            Assert.AreEqual(3, synced.Count, "Synced count wrong (br)");
            Assert.AreEqual(4, source.Count, "source count wrong (br)");
            Assert.AreEqual(0, synced.Where(_ => _.Id == 12).Count(), "synced contains 12");

            source.RemoveAt(3);

            count = 0;
            foreach (var item in synced)
            {
                count++;
            }

            Assert.AreEqual(3, count, "Calculated count wrong");
            Assert.AreEqual(3, synced.Count, "Synced count wrong");
            Assert.AreEqual(3, source.Count, "source count wrong");
            Assert.AreEqual(0, synced.Where(_ => _.Id == 12).Count(), "synced contains 12");
        }
Example #3
0
        public void Blb2Loc_ResultToSync()
        {
            var source = new TestList();
            var synced = (from r in source
                          where r.Id > 100
                          select r).ToSyncList(source);

            Assert.AreEqual(3, synced.Count);
        }
Example #4
0
        public void Blb2Loc_Ordered()
        {
            var source = new TestList();
            var synced = source.ToSyncList(from r in source
                                           orderby r.Name
                                           select r);

            Assert.AreEqual(453, synced[0].Id);
            Assert.AreEqual(123, synced[3].Id);
        }
Example #5
0
        public void Blb2Loc_Add()
        {
            var source = new TestList();
            var query  = from r in source
                         where r.Id > 100
                         select r;
            var synced = source.ToSyncList(query);

            var newItem = Csla.DataPortal.FetchChild <TestItem>(432, "New item");

            synced.Add(newItem);

            Assert.AreEqual(4, synced.Count, "synced should have item");
            Assert.AreEqual(5, source.Count, "source should have item");
            Assert.IsTrue(synced.Contains(newItem), "synced should contain new item");
            Assert.IsTrue(source.Contains(newItem), "source should contain new item");
        }
Example #6
0
        public void Blb2Loc_Remove()
        {
            var source = new TestList();
            var query  = from r in source
                         where r.Id > 100
                         select r;
            var synced = source.ToSyncList(query);

            var oldItem = synced[0];

            synced.RemoveAt(0);

            Assert.AreEqual(2, synced.Count, "synced count wrong");
            Assert.AreEqual(3, source.Count, "source count wrong");
            Assert.IsFalse(synced.Contains(oldItem), "synced should not contain item");
            Assert.IsFalse(source.Contains(oldItem), "source should not contain item");
        }