Beispiel #1
0
        public void apply_should_apply_configured_conventions()
        {
            // arrange
            var controllerType  = typeof(v2.UndecoratedController).GetTypeInfo();
            var action          = controllerType.GetRuntimeMethod(nameof(v2.UndecoratedController.Get), Type.EmptyTypes);
            var attributes      = Array.Empty <object>();
            var actionModel     = new ActionModel(action, attributes);
            var controllerModel = new ControllerModel(controllerType, attributes)
            {
                Actions = { actionModel }
            };
            var conventionBuilder = new ApiVersionConventionBuilder();
            var actionDescriptor  = new ActionDescriptor();

            conventionBuilder.Add(new VersionByNamespaceConvention());

            // act
            conventionBuilder.ApplyTo(controllerModel);
            actionDescriptor.SetProperty(controllerModel);
            actionDescriptor.SetProperty(actionModel.GetProperty <ApiVersionModel>());

            // assert
            actionDescriptor.MappingTo(new ApiVersion(2, 0)).Should().Be(Implicit);
        }