Beispiel #1
0
 public void Teardown()
 {
     _irrelevantApiDescriptionBuilder = null;
     _apiDocumentation   = null;
     _descriptionBuilder = null;
     _irrelevantControllerDescriptionBuilder = null;
     _controllerDescriptionBuilder           = null;
     _apiDescriptionBuilder        = null;
     _apiDescriptionBuilderFactory = null;
 }
Beispiel #2
0
        public EntryPointDescriptionController(
            Url entryPoint,
            IEntityContextProvider entityContextProvider,
            IApiEntryPointDescriptionBuilder apiDescriptionBuilder,
            INamedGraphSelectorFactory namedGraphSelectorFactory) :
            base(entityContextProvider, apiDescriptionBuilder, namedGraphSelectorFactory)
        {
            if (entryPoint == null)
            {
                throw new ArgumentNullException("entryPoint");
            }

            (_apiDescriptionBuilder = apiDescriptionBuilder).EntryPoint = entryPoint;
        }
        public EntryPointDescriptionController(
            Url entryPoint,
            IEntityContextProvider entityContextProvider,
            IApiEntryPointDescriptionBuilder apiDescriptionBuilder,
            INamedGraphSelectorFactory namedGraphSelectorFactory) :
            base(entityContextProvider, apiDescriptionBuilder, namedGraphSelectorFactory)
        {
            if (entryPoint == null)
            {
                throw new ArgumentNullException("entryPoint");
            }

            (_apiDescriptionBuilder = apiDescriptionBuilder).EntryPoint = entryPoint;
        }
Beispiel #4
0
        public void Setup()
        {
            HttpUrl requestUrl   = (HttpUrl)UrlParser.Parse("/test");
            var     classMapping = new Mock <IClassMapping>(MockBehavior.Strict);

            classMapping.SetupGet(instance => instance.Uri).Returns(EntityConverter.Hydra.AddFragment("ApiDocumentation"));
            var mapping = new Mock <IEntityMapping>(MockBehavior.Strict);

            mapping.SetupGet(instance => instance.Classes).Returns(new[] { classMapping.Object });
            var mappings = new Mock <IMappingsRepository>(MockBehavior.Strict);

            mappings.Setup(instance => instance.MappingFor(typeof(IApiDocumentation))).Returns(mapping.Object);
            var classEntity     = new Mock <IClass>(MockBehavior.Strict);
            var baseUriSelector = new Mock <IBaseUriSelectionPolicy>(MockBehavior.Strict);

            baseUriSelector.Setup(instance => instance.SelectBaseUri(It.IsAny <EntityId>())).Returns(new Uri("http://temp.uri/"));
            var context = new Mock <IEntityContext>(MockBehavior.Strict);

            context.SetupGet(instance => instance.BaseUriSelector).Returns(baseUriSelector.Object);
            context.SetupGet(instance => instance.Mappings).Returns(mappings.Object);
            context.Setup(instance => instance.Create <IClass>(It.IsAny <EntityId>())).Returns(classEntity.Object);
            _apiDocumentation = new Mock <IApiDocumentation>(MockBehavior.Strict);
            _apiDocumentation.SetupGet(instance => instance.Context).Returns(context.Object);
            _apiDocumentation.SetupGet(instance => instance.SupportedClasses).Returns(new List <IClass>());
            _irrelevantApiDescriptionBuilder = new Mock <IApiDescriptionBuilder>(MockBehavior.Strict);
            _apiDescriptionBuilder           = new Mock <IApiDescriptionBuilder <TestController> >(MockBehavior.Strict);
            _apiDescriptionBuilder.Setup(instance => instance.BuildDescription(_apiDocumentation.Object, null));
            _apiDescriptionBuilderFactory = new Mock <IApiDescriptionBuilderFactory>(MockBehavior.Strict);
            _apiDescriptionBuilderFactory.Setup(instance => instance.Create(It.Is <Type>(type => type == typeof(TestController)))).Returns(_apiDescriptionBuilder.Object);
            string callUri;
            var    controllerDescription = new ControllerInfo <TestController>(
                EntryPoint,
                requestUrl.InsertSegments(0, ((HttpUrl)EntryPoint.Url).Segments),
                typeof(TestController).GetMethod("Add").ToOperationInfo(requestUrl.InsertSegments(0, ((HttpUrl)EntryPoint.Url).Segments).ToString(), Verb.GET, out callUri));

            _irrelevantControllerDescriptionBuilder = new Mock <IHttpControllerDescriptionBuilder>(MockBehavior.Strict);
            _controllerDescriptionBuilder           = new Mock <IHttpControllerDescriptionBuilder <TestController> >(MockBehavior.Strict);
            _controllerDescriptionBuilder.As <IHttpControllerDescriptionBuilder>().Setup(instance => instance.BuildDescriptor()).Returns(controllerDescription);
            var entryPointControllerDescription = new ControllerInfo <EntryPointDescriptionController>(null, UrlParser.Parse("/test"));

            _entryPointControllerDescriptionBuilder = new Mock <IHttpControllerDescriptionBuilder <EntryPointDescriptionController> >(MockBehavior.Strict);
            _entryPointControllerDescriptionBuilder.As <IHttpControllerDescriptionBuilder>().Setup(instance => instance.BuildDescriptor()).Returns(entryPointControllerDescription);
            _descriptionBuilder = new ApiEntryPointDescriptionBuilder(
                _apiDescriptionBuilderFactory.Object,
                new[] { _controllerDescriptionBuilder.Object, _irrelevantControllerDescriptionBuilder.Object, _entryPointControllerDescriptionBuilder.Object });
            _descriptionBuilder.EntryPoint = EntryPoint;
        }
 public void Setup()
 {
     HttpUrl requestUrl = (HttpUrl)UrlParser.Parse("/test");
     var classMapping = new Mock<IClassMapping>(MockBehavior.Strict);
     classMapping.SetupGet(instance => instance.Uri).Returns(EntityConverter.Hydra.AddFragment("ApiDocumentation"));
     var mapping = new Mock<IEntityMapping>(MockBehavior.Strict);
     mapping.SetupGet(instance => instance.Classes).Returns(new[] { classMapping.Object });
     var mappings = new Mock<IMappingsRepository>(MockBehavior.Strict);
     mappings.Setup(instance => instance.MappingFor(typeof(IApiDocumentation))).Returns(mapping.Object);
     var classEntity = new Mock<IClass>(MockBehavior.Strict);
     var baseUriSelector = new Mock<IBaseUriSelectionPolicy>(MockBehavior.Strict);
     baseUriSelector.Setup(instance => instance.SelectBaseUri(It.IsAny<EntityId>())).Returns(new Uri("http://temp.uri/"));
     var context = new Mock<IEntityContext>(MockBehavior.Strict);
     context.SetupGet(instance => instance.BaseUriSelector).Returns(baseUriSelector.Object);
     context.SetupGet(instance => instance.Mappings).Returns(mappings.Object);
     context.Setup(instance => instance.Create<IClass>(It.IsAny<EntityId>())).Returns(classEntity.Object);
     _apiDocumentation = new Mock<IApiDocumentation>(MockBehavior.Strict);
     _apiDocumentation.SetupGet(instance => instance.Context).Returns(context.Object);
     _apiDocumentation.SetupGet(instance => instance.SupportedClasses).Returns(new List<IClass>());
     _irrelevantApiDescriptionBuilder = new Mock<IApiDescriptionBuilder>(MockBehavior.Strict);
     _apiDescriptionBuilder = new Mock<IApiDescriptionBuilder<TestController>>(MockBehavior.Strict);
     _apiDescriptionBuilder.Setup(instance => instance.BuildDescription(_apiDocumentation.Object, null));
     _apiDescriptionBuilderFactory = new Mock<IApiDescriptionBuilderFactory>(MockBehavior.Strict);
     _apiDescriptionBuilderFactory.Setup(instance => instance.Create(It.Is<Type>(type => type == typeof(TestController)))).Returns(_apiDescriptionBuilder.Object);
     string callUri;
     var controllerDescription = new ControllerInfo<TestController>(
         EntryPoint,
         requestUrl.InsertSegments(0, ((HttpUrl)EntryPoint.Url).Segments),
         typeof(TestController).GetMethod("Add").ToOperationInfo(requestUrl.InsertSegments(0, ((HttpUrl)EntryPoint.Url).Segments).ToString(), Verb.GET, out callUri));
     _irrelevantControllerDescriptionBuilder = new Mock<IHttpControllerDescriptionBuilder>(MockBehavior.Strict);
     _controllerDescriptionBuilder = new Mock<IHttpControllerDescriptionBuilder<TestController>>(MockBehavior.Strict);
     _controllerDescriptionBuilder.As<IHttpControllerDescriptionBuilder>().Setup(instance => instance.BuildDescriptor()).Returns(controllerDescription);
     var entryPointControllerDescription = new ControllerInfo<EntryPointDescriptionController>(null, UrlParser.Parse("/test"));
     _entryPointControllerDescriptionBuilder = new Mock<IHttpControllerDescriptionBuilder<EntryPointDescriptionController>>(MockBehavior.Strict);
     _entryPointControllerDescriptionBuilder.As<IHttpControllerDescriptionBuilder>().Setup(instance => instance.BuildDescriptor()).Returns(entryPointControllerDescription);
     _descriptionBuilder = new ApiEntryPointDescriptionBuilder(
         _apiDescriptionBuilderFactory.Object,
         new[] { _controllerDescriptionBuilder.Object, _irrelevantControllerDescriptionBuilder.Object, _entryPointControllerDescriptionBuilder.Object });
     _descriptionBuilder.EntryPoint = EntryPoint;
 }
 public void Teardown()
 {
     _irrelevantApiDescriptionBuilder = null;
     _apiDocumentation = null;
     _descriptionBuilder = null;
     _irrelevantControllerDescriptionBuilder = null;
     _controllerDescriptionBuilder = null;
     _apiDescriptionBuilder = null;
     _apiDescriptionBuilderFactory = null;
 }