public void NothingSet()
        {
            var s = new PersonIdSynchronizer();

            Assert.IsNull(s.Entity);
            Assert.AreEqual(0, s.Id);
            Assert.IsNull(s.IdOrNull);
            Assert.AreEqual(0, s.Key);
        }
        public void SetId()
        {
            var s = new PersonIdSynchronizer();

            s.Id = 1;

            Assert.AreEqual(1, s.Id);
            Assert.AreEqual(1, s.IdOrNull);
            Assert.AreEqual(1, s.Key);
            Assert.IsNull(s.Entity);
        }
        public void SetEntity()
        {
            var s   = new PersonIdSynchronizer();
            var bob = new Person {
                Id = 1, Name = "Bob"
            };

            s.Entity = bob;

            Assert.AreSame(bob, s.Entity);
            Assert.AreEqual(1, s.Id);
            Assert.AreEqual(1, s.IdOrNull);
            Assert.AreEqual(1, s.Key);
        }
        public void SetEntityThenIdNull()
        {
            var s   = new PersonIdSynchronizer();
            var bob = new Person {
                Id = 1, Name = "Bob"
            };

            s.Entity   = bob;
            s.IdOrNull = null;

            Assert.IsNull(s.Entity);
            Assert.AreEqual(0, s.Id);
            Assert.IsNull(s.IdOrNull);
            Assert.AreEqual(0, s.Key);
        }
        public void SetEntityThenId_IdDoesNotMatchEntity()
        {
            var s   = new PersonIdSynchronizer();
            var bob = new Person {
                Id = 1, Name = "Bob"
            };

            s.Entity = bob;
            s.Id     = 2;

            Assert.AreEqual(2, s.Id);
            Assert.AreEqual(2, s.IdOrNull);
            Assert.AreEqual(2, s.Key);
            Assert.IsNull(s.Entity);
        }
        public void SerializeThenDeserialize()
        {
            var s   = new PersonIdSynchronizer();
            var bob = new Person {
                Id = 1, Name = "Bob"
            };

            s.Id     = 1;
            s.Entity = bob;

            var clone = SerializeUtils.Clone(s);

            Assert.AreNotSame(s, clone);
            Assert.AreEqual(1, clone.Id);
            Assert.AreEqual(bob.Id, clone.Entity.Id);
            Assert.AreEqual(bob.Name, clone.Entity.Name);
            Assert.AreNotSame(bob, clone.Entity);
        }