コード例 #1
0
        public void Test_GetEntityTypes_EntityRefWithNoEntity()
        {
            IDictionary <long, ISet <EntityRef> > result;
            List <EntityRef> testEntityRefs;
            EntityRef        entityRef;

            entityRef = new EntityRef(EntityTemporaryIdAllocator.AcquireId());
            try
            {
                // Sanity Check
                Assert.That(entityRef.Entity, Is.Null, "entityRef.Entity not null");

                testEntityRefs = new List <EntityRef>
                {
                    entityRef
                };

                result = new EntityTypeRepository().GetEntityTypes(testEntityRefs);

                Assert.That(result, Has.Count.EqualTo(1));
                Assert.That(result,
                            Has.Exactly(1)
                            .Property("Key")
                            .EqualTo(EntityTypeRepository.TypelessId)
                            .And.Property("Value")
                            .EquivalentTo(testEntityRefs)
                            .Using(EntityRefComparer.Instance),
                            "Relationship entity IDs missing");
            }
            finally
            {
                EntityTemporaryIdAllocator.RelinquishId(entityRef.Id);
            }
        }
コード例 #2
0
        public void Test_GetEntityTypes_TypelessEntity()
        {
            IDictionary <long, ISet <EntityRef> > result;
            List <EntityRef> testEntityRefs;

            // Sanity Check
            Assert.That(new EntityRef(EntityId.Max).HasEntity, Is.False, "EntityId.Max.HasEntity");

            testEntityRefs = new List <EntityRef>()
            {
                new EntityRef(EntityTemporaryIdAllocator.AcquireId())
            };

            try
            {
                result = new EntityTypeRepository(x => new HashSet <long>()).GetEntityTypes(testEntityRefs);

                Assert.That(result, Has.Count.EqualTo(1));
                Assert.That(result,
                            Has.Exactly(1)
                            .Property("Key")
                            .EqualTo(EntityTypeRepository.TypelessId)
                            .And.Property("Value")
                            .EquivalentTo(testEntityRefs)
                            .Using(EntityRefComparer.Instance),
                            "Relationship entity IDs missing");
            }
            finally
            {
                EntityTemporaryIdAllocator.RelinquishId(testEntityRefs[0].Id);
            }
        }
コード例 #3
0
        public void Test_AllowAccessToTemporaryIds()
        {
            const long nonTemporaryId = 1;
            long       temporaryId    = EntityTemporaryIdAllocator.AcquireId();
            Dictionary <long, bool> mapping;

            try
            {
                mapping = new Dictionary <long, bool>
                {
                    { temporaryId, false },
                    { nonTemporaryId, false }
                };

                new EntityAccessControlChecker().AllowAccessToTemporaryIds(mapping);

                Assert.That(mapping, Has.Property("Count").EqualTo(2));
                Assert.That(mapping, Has.Exactly(1).Property("Key").EqualTo(temporaryId).And.Property("Value").True);
                Assert.That(mapping, Has.Exactly(1).Property("Key").EqualTo(nonTemporaryId).And.Property("Value").False);
            }
            finally
            {
                EntityTemporaryIdAllocator.RelinquishId(temporaryId);
            }
        }