public void Apply_NullAttributeRouteModel_NoOp()
        {
            // Arrange
            var convention = new RouteTokenTransformerConvention(new TestParameterTransformer());

            var model = new ActionModel(GetMethodInfo(), Array.Empty <object>());

            model.Selectors.Add(new SelectorModel()
            {
                AttributeRouteModel = null
            });

            // Act
            convention.Apply(model);

            // Assert
            Assert.Null(model.Selectors[0].AttributeRouteModel);
        }
    public void Apply_HasAttributeRouteModel_SetRouteTokenTransformer()
    {
        // Arrange
        var transformer = new TestParameterTransformer();
        var convention  = new RouteTokenTransformerConvention(transformer);

        var model = new ActionModel(GetMethodInfo(), Array.Empty <object>());

        model.Selectors.Add(new SelectorModel()
        {
            AttributeRouteModel = new AttributeRouteModel()
        });

        // Act
        convention.Apply(model);

        // Assert
        Assert.Same(transformer, model.RouteParameterTransformer);
    }
Example #3
0
        public void Apply_HasAttributeRouteModel_SetRouteTokenTransformer()
        {
            // Arrange
            var transformer = new TestParameterTransformer();
            var convention  = new RouteTokenTransformerConvention(transformer);

            var model = new ActionModel(GetMethodInfo(), Array.Empty <object>());

            model.Selectors.Add(new SelectorModel()
            {
                AttributeRouteModel = new AttributeRouteModel()
            });

            // Act
            convention.Apply(model);

            // Assert
            Assert.True(model.Properties.TryGetValue(typeof(IOutboundParameterTransformer), out var routeTokenTransformer));
            Assert.Equal(transformer, routeTokenTransformer);
        }