示例#1
0
    public void OnProvidersExecuting_DoesNotAddFilter_IfTypeHasNoViewDataProperties()
    {
        // Arrange
        var type     = typeof(TestPageModel_NoViewDataProperties);
        var provider = new ViewDataAttributePageApplicationModelProvider();
        var context  = CreateProviderContext(type);

        // Act
        provider.OnProvidersExecuting(context);

        // Assert
        Assert.Empty(context.PageApplicationModel.Filters);
    }
示例#2
0
    public void AddsViewDataPropertyFilter_ForViewDataAttributeProperties()
    {
        // Arrange
        var type     = typeof(TestPageModel_ViewDataProperties);
        var provider = new ViewDataAttributePageApplicationModelProvider();
        var context  = CreateProviderContext(type);

        // Act
        provider.OnProvidersExecuting(context);

        // Assert
        var filter         = Assert.Single(context.PageApplicationModel.Filters);
        var viewDataFilter = Assert.IsType <PageViewDataAttributeFilterFactory>(filter);

        Assert.Collection(
            viewDataFilter.Properties,
            property => Assert.Equal(nameof(TestPageModel_ViewDataProperties.DateTime), property.PropertyInfo.Name));
    }