示例#1
0
        public void WriteAsyncTests()
        {
            var personsRealm = new PersonsRealmService();

            personsRealm.Write(() => personsRealm.RemoveAll());
            RunAsyncServiceTests().Wait();
            personsRealm.RefreshRealmInstance();
            var sorted = personsRealm.GetAll().OrderBy(x => x.Id).ToList();

            Assert.That(sorted.Count, Is.EqualTo(50000));
            var firstId = sorted.First().Id;
            var lastId  = sorted.Last().Id;
            var total   = lastId - firstId + 1;

            Assert.That(total, Is.EqualTo(50000));
            personsRealm.Write(() => personsRealm.RemoveAll());
        }
示例#2
0
        protected void RunServiceTests()
        {
            var realmService = RealmService.GetInstance <Models.Person>();

            realmService.Write(() =>
            {
                realmService.Add(new Person {
                    Name = "Greg"
                });
                realmService.Add(new Person {
                    Name = "Jim"
                });
                realmService.Add(new Person {
                    Name = "Bob"
                });
            });

            // OR

            var personsRealm = new PersonsRealmService();

            personsRealm.Write(() =>
            {
                personsRealm.Add(new Person {
                    Name = "Jan"
                });
                personsRealm.Add(new Person {
                    Name = "June"
                });
                personsRealm.Add(new Person {
                    Name = "Jinny"
                });
            });

            var persons = personsRealm.GetAll().ToList();

            personsRealm.Write(() =>
            {
                personsRealm.RemoveAll();
            });
        }
示例#3
0
        protected async void RunAsyncServiceTests()
        {
            await Task.WhenAll(
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest(),
                RunAsyncTest());

            var personsRealm = new PersonsRealmService();
            var persons      = personsRealm.GetAll().ToList();

            personsRealm.Write(() =>
            {
                personsRealm.RemoveAll();
            });
        }