Esempio n. 1
0
        public void Test_WithType_NullIdentity(string identity)
        {
            IResourceResolverProvider provider = GetResolverProvider( );
            IResourceResolver         resolver = provider.GetResolverForType(new EntityRef("test:employee").Id);

            Assert.Throws <ArgumentNullException>(() => resolver.ResolveResource(identity));
        }
Esempio n. 2
0
        public void Test_ResolveMultiple_Null( )
        {
            long typeId = new EntityType( ).Id;

            IResourceResolverProvider provider = GetResolverProvider( );
            IResourceResolver         resolver = provider.GetResolverForType(typeId);

            Assert.Throws <ArgumentNullException>(() => resolver.ResolveResources(null));
        }
Esempio n. 3
0
        public void Test_ResolveMultiple_Empty( )
        {
            long typeId = new EntityType( ).Id;

            IResourceResolverProvider provider = GetResolverProvider( );
            IResourceResolver         resolver = provider.GetResolverForType(typeId);

            var entities = resolver.ResolveResources(new string [] { });

            Assert.That(entities.Count, Is.EqualTo(0));
        }
Esempio n. 4
0
        public void Test_Resolve_WithType_NotFound(string identity, string type, ResourceResolverError expectedError)
        {
            IResourceResolverProvider provider = GetResolverProvider( );
            long typeId = new EntityRef(type).Id;
            IResourceResolver resolver = provider.GetResolverForType(typeId);

            ResourceResolverEntry entry = resolver.ResolveResource(identity);

            Assert.That(entry.Entity, Is.Null);
            Assert.That(entry.Error, Is.EqualTo(expectedError));
        }
Esempio n. 5
0
        public void Test_ResolveResource_WithType_ByName(string identity, string type)
        {
            IResourceResolverProvider provider = GetResolverProvider( );
            long typeId = new EntityRef(type).Id;
            IResourceResolver resolver = provider.GetResolverForType(typeId);

            ResourceResolverEntry entry = resolver.ResolveResource(identity);
            IEntity entity = entry.Entity;

            Assert.That(entity, Is.Not.Null);
            Assert.That(entity.As <Resource>( ).Name, Is.EqualTo(identity));
        }
Esempio n. 6
0
        public void Test_ResolveMultiple_WithType_ByName( )
        {
            string [] names = new [] { "David Quint", "Peter Aylett" };

            IResourceResolverProvider provider = GetResolverProvider( );
            long typeId = new EntityRef("test:employee").Id;
            IResourceResolver resolver = provider.GetResolverForType(typeId);

            var entities = resolver.ResolveResources(names);

            Assert.That(entities, Is.Not.Null);
            Assert.That(entities.Count, Is.EqualTo(2));
        }
Esempio n. 7
0
        public void Test_ResolveMultiple_WithType_ByGuid( )
        {
            string [] aliases = new [] { "test:aaDavidQuint", "test:aaPeterAylett" };
            string [] guids   = aliases.Select(alias => Entity.Get(new EntityRef(alias)).UpgradeId.ToString( )).ToArray( );

            IResourceResolverProvider provider = GetResolverProvider( );
            long typeId = new EntityRef("test:employee").Id;
            IResourceResolver resolver = provider.GetResolverForType(typeId);

            var entities = resolver.ResolveResources(guids);

            Assert.That(entities, Is.Not.Null);
            Assert.That(entities.Count, Is.EqualTo(2));
        }
Esempio n. 8
0
        public void Test_ResolveResource_WithType_ByGuid(string alias, string type, string name)
        {
            IEntity entity1  = Entity.Get(new EntityRef(alias));
            string  identity = entity1.UpgradeId.ToString( );

            IResourceResolverProvider provider = GetResolverProvider( );
            long typeId = new EntityRef(type).Id;
            IResourceResolver resolver = provider.GetResolverForType(typeId);

            ResourceResolverEntry entry = resolver.ResolveResource(identity);
            IEntity entity = entry.Entity;

            Assert.That(entity, Is.Not.Null);
            Assert.That(entity.As <Resource>( ).Name, Is.EqualTo(name));
        }