Exemple #1
0
    public void CreateService_UnwrapsFilterFactory()
    {
        // Arrange
        var serviceProvider = new ServiceCollection()
                              .AddSingleton(new TestFilterFactory())
                              .BuildServiceProvider();

        var serviceFilter = new ServiceFilterAttribute(typeof(TestFilterFactory));

        // Act
        var filter = serviceFilter.CreateInstance(serviceProvider);

        // Assert
        Assert.IsType <TestFilter>(filter);
    }
Exemple #2
0
    public void CreateService_GetsFilterFromServiceProvider()
    {
        // Arrange
        var expected        = new TestFilter();
        var serviceProvider = new ServiceCollection()
                              .AddSingleton(expected)
                              .BuildServiceProvider();

        var serviceFilter = new ServiceFilterAttribute(typeof(TestFilter));

        // Act
        var filter = serviceFilter.CreateInstance(serviceProvider);

        // Assert
        Assert.Same(expected, filter);
    }