public void AddOrUpdate_WhenNoPrimaryKey_ShouldAdd()
        {
            var noPK = new NonPrimaryKeyObject
            {
                StringValue = "123"
            };

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

            var noPK2 = new NonPrimaryKeyObject
            {
                StringValue = "123"
            };

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

            Assert.That(noPK2, Is.Not.EqualTo(noPK));
            Assert.That(_realm.All <NonPrimaryKeyObject>().Count(), Is.EqualTo(2));
        }
Exemplo n.º 2
0
        public void AddOrUpdate_WhenNoPrimaryKey_ShouldAdd()
        {
            var noPK = new NonPrimaryKeyObject
            {
                StringValue = "123"
            };

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

            var noPK2 = new NonPrimaryKeyObject
            {
                StringValue = "123"
            };

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

            Assert.That(noPK2, Is.Not.EqualTo(noPK));
            Assert.That(_realm.All<NonPrimaryKeyObject>().Count(), Is.EqualTo(2));
        }