public virtual void Test_Update_SetsCountPropertyForReference_TwoWay()
        {
            MockEntity entity = new MockEntity();
            entity.ID = Guid.NewGuid();

            MockSyncEntity referencedEntity = new MockSyncEntity();
            referencedEntity.ID = Guid.NewGuid();

            entity.SyncEntities = new MockSyncEntity[]{
                referencedEntity
            };

            DataAccess.Data.Saver.Save(referencedEntity);
            DataAccess.Data.Saver.Save(entity);

            DataAccess.Data.Updater.Update(entity);

            MockEntity foundEntity = DataAccess.Data.Reader.GetEntity<MockEntity>("ID", entity.ID);
            MockSyncEntity foundReferencedEntity = DataAccess.Data.Reader.GetEntity<MockSyncEntity>("ID", referencedEntity.ID);

            DataAccess.Data.Activator.Activate(foundEntity);
            DataAccess.Data.Activator.Activate(foundReferencedEntity);

            Assert.AreEqual(1, foundEntity.TotalSyncEntities, "The TotalSyncEntities property didn't have the expected value.");
            Assert.AreEqual(1, foundEntity.SyncEntities.Length, "The SyncEntities property didn't have the expected length.");

            Assert.AreEqual(1, foundReferencedEntity.TotalEntities, "The TotalEntities property didn't have the expected value.");
            Assert.AreEqual(1, foundReferencedEntity.Entities.Length, "The Entities property didn't have the expected length.");
        }
        public void Test_SwitchFor()
        {
            MockEntity entity = new MockEntity();
            entity.ID = Guid.NewGuid();

            MockSyncEntity otherEntity = new MockSyncEntity();
            otherEntity.ID = Guid.NewGuid();

            entity.SyncEntities = new MockSyncEntity[]{
                otherEntity
            };

            EntityReference reference = new EntityReference();
            reference.SourceEntity = entity;
            reference.ReferenceEntity = otherEntity;
            reference.Property1Name = "SyncEntities";
            reference.Property2Name = "Entities";

            EntityReference switchedReference = reference.SwitchFor(otherEntity);

            Assert.AreEqual(reference.Property1Name, "Entities", "Property1Name doesn't match what's expected.");
            Assert.AreEqual(reference.Property2Name, "SyncEntities", "Property2Name doesn't match what's expected.");

            Assert.AreEqual(reference.Type1Name.ToString(), otherEntity.ShortTypeName, "Type1Name doesn't match what's expected.");
            Assert.AreEqual(reference.Type2Name.ToString(), entity.ShortTypeName, "Type2Name doesn't match what's expected.");

            Assert.AreEqual(reference.Entity1ID.ToString(), otherEntity.ID.ToString(), "Entity1ID doesn't match what's expected.");
            Assert.AreEqual(reference.Entity2ID.ToString(), entity.ID.ToString(), "Entity2ID doesn't match what's expected.");
        }
        public virtual void Test_SetCountProperty_TwoWayReference()
        {
            MockEntity entity = new MockEntity();
            entity.ID = Guid.NewGuid();

            MockSyncEntity referencedEntity = new MockSyncEntity();
            referencedEntity.ID = Guid.NewGuid();

            entity.SyncEntities = new MockSyncEntity[]{
                referencedEntity
            };

            EntityReferenceCollection references = DataAccess.Data.Referencer.GetActiveReferences(entity);

            DataAccess.Data.Saver.Save(referencedEntity);
            DataAccess.Data.Saver.Save(entity);

            DataAccess.Data.Referencer.SetCountProperty(entity, "SyncEntities", referencedEntity.ID);

            Assert.AreEqual(1, entity.TotalSyncEntities, "The TotalSyncEntities property didn't have the expected value.");
        }
        public virtual void Test_Save_SetsCountPropertyForReference()
        {
            using (LogGroup logGroup = LogGroup.StartDebug("Testing the Save function to ensure it sets the reference count properties."))
            {
                MockEntity entity = new MockEntity();
                entity.ID = Guid.NewGuid();

                MockSyncEntity referencedEntity = new MockSyncEntity();
                referencedEntity.ID = Guid.NewGuid();

                entity.SyncEntities = new MockSyncEntity[]{
                    referencedEntity
                };

                DataAccess.Data.Saver.Save(referencedEntity);
                DataAccess.Data.Saver.Save(entity);

                MockEntity foundEntity = DataAccess.Data.Reader.GetEntity<MockEntity>("ID", entity.ID);
                MockSyncEntity foundReferencedEntity = DataAccess.Data.Reader.GetEntity<MockSyncEntity>("ID", referencedEntity.ID);

                DataAccess.Data.Activator.Activate(foundEntity);
                DataAccess.Data.Activator.Activate(foundReferencedEntity);

                Assert.AreEqual(1, foundEntity.TotalSyncEntities, "The TotalSyncEntities property didn't have the expected value.");
                Assert.AreEqual(1, foundEntity.SyncEntities.Length, "The SyncEntities property didn't have the expected length.");

                Assert.AreEqual(1, foundReferencedEntity.TotalEntities, "The TotalEntities property didn't have the expected value.");
                Assert.AreEqual(1, foundReferencedEntity.Entities.Length, "The Entities property didn't have the expected length.");
            }
        }