Example #1
0
        public void AddOrUpdate_WhenPKIsNull_ShouldUpdate()
        {
            var first = new NullablePrimaryKeyObject
            {
                StringValue = "first"
            };

            _realm.Write(() =>
            {
                _realm.Add(first, update: true);
            });

            var second = new NullablePrimaryKeyObject
            {
                StringValue = "second"
            };

            _realm.Write(() =>
            {
                _realm.Add(second, update: true);
            });

            Assert.That(first.StringValue, Is.EqualTo("second"));
            Assert.That(second.StringValue, Is.EqualTo("second"));
            Assert.That(_realm.All <NullablePrimaryKeyObject>().Count(), Is.EqualTo(1));
        }
Example #2
0
        public void AddOrUpdate_WhenPKIsNull_ShouldUpdate()
        {
            var first = new NullablePrimaryKeyObject
            {
                StringValue = "first"
            };

            _realm.Write(() =>
            {
                _realm.Add(first, update: true);
            });

            var second = new NullablePrimaryKeyObject
            {
                StringValue = "second"
            };

            _realm.Write(() =>
            {
                _realm.Add(second, update: true);
            });

            Assert.That(first.StringValue, Is.EqualTo("second"));
            Assert.That(second.StringValue, Is.EqualTo("second"));
            Assert.That(_realm.All<NullablePrimaryKeyObject>().Count(), Is.EqualTo(1));
        }