public void Create_WhenBindingSourceIsFromServices_ReturnsBinder()
    {
        // Arrange
        var provider = new ServicesModelBinderProvider();

        var context = new TestModelBinderProviderContext(typeof(IPersonService));

        context.BindingInfo.BindingSource = BindingSource.Services;

        // Act
        var result = provider.GetBinder(context);

        // Assert
        Assert.IsType <ServicesModelBinder>(result);
    }
Esempio n. 2
0
    public void Create_WhenBindingSourceIsNullableFromServices_ReturnsBinder(ParameterInfo parameterInfo, bool isOptional)
    {
        // Arrange
        var provider = new ServicesModelBinderProvider();

        var context = new TestModelBinderProviderContext(parameterInfo);

        // Act
        var result = provider.GetBinder(context);

        // Assert
        var binder = Assert.IsType <ServicesModelBinder>(result);

        Assert.Equal(isOptional, binder.IsOptional);
    }