コード例 #1
0
        public void Getting_absoulte_template_should_throw_wen_there_is_no_base_URI()
        {
            // given
            var type     = typeof(Collection <ModelWithTemplate>);
            var provider = new AttributeModelTemplateProvider();

            // then
            Assert.Throws <MissingTemplateException>(() => provider.GetAbsoluteTemplate(type));
        }
コード例 #2
0
        public EntityFrameworkSourceTestContext()
        {
            var sourceContext    = new SourceContext(Database.TestConnectionString);
            var configuration    = new TestConfiguration();
            var templateProvider = new AttributeModelTemplateProvider(configuration);

            Repository = new SourcesRepository(
                sourceContext,
                new EntityFactory(new TunnelVisionLabsUriTemplateExpander(templateProvider), configuration),
                new TunnelVisionLabsUriTemplateMatcher(templateProvider));
        }
コード例 #3
0
        public void Getting_template_for_Hydra_collection_should_retrieve_it_from_attribute()
        {
            // given
            var type     = typeof(Collection <ModelWithTemplate>);
            var provider = new AttributeModelTemplateProvider();

            // when
            var template = provider.GetTemplate(type);

            // then
            template.Should().Be("multiple/models");
        }
コード例 #4
0
        public void Getting_template_for_model_should_prefix_attribute_value_with_base()
        {
            // given
            var type     = typeof(ModelWithTemplate);
            var provider = new AttributeModelTemplateProvider(new FakeBaseUriProvider());

            // when
            var template = provider.GetAbsoluteTemplate(type);

            // then
            template.Should().Be("http://example.com/model/with/template");
        }
コード例 #5
0
        public void Getting_template_for_model_should_throw_if_template_isnt_found()
        {
            // given
            var type     = typeof(AttributeModelTemplateProviderTests);
            var provider = new AttributeModelTemplateProvider();

            // when
            var ex = Assert.Throws <MissingTemplateException>(() => provider.GetTemplate(type));

            // then
            ex.Message.Should().Be($"Template not found for type {type.FullName}");
        }
コード例 #6
0
        public void Getting_template_for_model_should_retrieve_it_from_attribute()
        {
            // given
            var type     = typeof(ModelWithTemplate);
            var provider = new AttributeModelTemplateProvider();

            // when
            var template = provider.GetTemplate(type);

            // then
            template.Should().Be("model/with/template");
        }