コード例 #1
0
        public void Test_Save_RemovesUnauthorisedReferences()
        {
            MockEntity entity = new MockEntity();

            entity.ID = Guid.NewGuid();

            MockRestrictedEntity restrictedEntity = new MockRestrictedEntity();

            restrictedEntity.ID = Guid.NewGuid();

            entity.RestrictedEntities = new MockRestrictedEntity[] {
                restrictedEntity
            };

            SaveStrategy.New(restrictedEntity, false).Save(restrictedEntity);
            SaveStrategy.New(entity).Save(entity);

            MockEntity foundEntity = RetrieveStrategy.New <MockEntity>(false).Retrieve <MockEntity>("ID", entity.ID);

            Assert.IsNotNull(foundEntity);

            foundEntity.Activate();

            Assert.AreEqual(0, foundEntity.RestrictedEntities.Length, "Restricted entity wasn't removed from reference property.");
        }