Esempio n. 1
0
        private void RunUnmanagedTests <T>(Func <ListsObject, IList <T> > accessor, T[] toAdd)
        {
            try
            {
                if (toAdd == null)
                {
                    toAdd = Array.Empty <T>();
                }

                var listsObject = new ListsObject();
                var list        = accessor(listsObject);

                foreach (var item in toAdd)
                {
                    list.Add(item);
                }

                CollectionAssert.AreEqual(list, toAdd);

                _realm.Write(() => _realm.Add(listsObject));

                var managedList = accessor(listsObject);

                CollectionAssert.AreEqual(managedList, toAdd);
            }
            finally
            {
                _realm.Dispose();
            }
        }
 private void RunManagedTests <T>(Func <ListsObject, IList <T> > itemsGetter, T[] toAdd)
 {
     TestHelpers.RunAsyncTest(async() =>
     {
         var listObject = new ListsObject();
         _realm.Write(() => _realm.Add(listObject));
         var items = itemsGetter(listObject);
         await RunManagedTestsCore(items, toAdd);
     }, timeout: 100000);
 }
        private void RunUnmanagedTests <T>(Func <ListsObject, IList <T> > listGetter, T[] testList)
        {
            var listObject = new ListsObject();
            var list       = listGetter(listObject);

            var testData = new ListTestCaseData <T>(testList);

            testData.Seed(list);

            RunTestsCore(testData, list);
        }
Esempio n. 4
0
        public void PrimitiveList_WhenEnumerating_ShouldBeStable()
        {
            var container = new ListsObject();

            _realm.Write(() => _realm.Add(container));

            TestStableIteration(
                container.Int32List.Add,
                () => container.Int32List,
                i => container.Int32List.Remove(i));

            Assert.That(container.Int32List, Is.Empty);
        }
        private void RunManagedTests <T>(Func <ListsObject, IList <T> > listGetter, T[] testList)
        {
            TestHelpers.RunAsyncTest(async() =>
            {
                var listObject = new ListsObject();
                var list       = listGetter(listObject);

                var testData = new ListTestCaseData <T>(testList);
                testData.Seed(list);

                _realm.Write(() => _realm.Add(listObject));

                var managedList = listGetter(listObject);

                Assert.That(list, Is.Not.SameAs(managedList));

                RunTestsCore(testData, managedList);

                await testData.AssertThreadSafeReference(managedList);
                testData.AssertNotifications(managedList);
            }, timeout: 100000);
        }