Beispiel #1
0
 /// <summary>
 /// Заполнение данных реальных объектов с БД.
 /// </summary>
 public void FillData <T, TReal>(XPCollection xpCollection, CollectionEx <TReal> realCollection)
 {
     realCollection.Clear();
     foreach (T server in xpCollection)
     {
         realCollection.Add((TReal)Activator.CreateInstance(typeof(TReal), server, ItemRealCollection));
     }
 }
        public void CanClearItems()
        {
            var c = new CollectionEx<int>();

            c.Add(1);
            c.Add(2);

            c.Clear();

            Assert.AreEqual(0, c.Count);
        }
        public void Clear__TriggersVersionChangedEvent()
        {
            var c = new CollectionEx<int>();

            c.Add(13);
            c.Add(7);

            var eventCalled = false;
            var lastVersion = c.Version;

            c.VersionChanged += (s, e) =>
            {
                if (eventCalled)
                    Assert.Fail("VersionChanged should be triggered only once during bulk updates");

                eventCalled = true;
            };

            c.Clear();

            Assert.IsTrue(eventCalled);
            Assert.AreNotEqual(lastVersion, c.Version);
            Assert.AreEqual(0, c.Count);
        }
        public void IsReadonly_Clear_ThrowsException()
        {
            var c = new CollectionEx<int>(new int[] { 1, 2 });

            c.Clear();
        }