public void CreateInstance_Should_Throw_If_Filter_Not_Injected() { // Act var provider = new ServiceCollection() .AddSingleton <SomeDependencyTest>() .BuildServiceProvider(true); var factory = new ServiceCommandFilterFactory(typeof(TestFilter)); // Arrange + Assert Assert.Throws <InvalidOperationException>(() => { _ = factory.CreateInstance(provider); }); }
public void CreateInstance_Should_Create_Filter_Instance_With_FilterFactory() { // Act var provider = new ServiceCollection() .AddSingleton <SomeDependencyTest>() .AddSingleton <TestFilterFactory>() .BuildServiceProvider(true); var factory = new ServiceCommandFilterFactory(typeof(TestFilterFactory)); // Arrange var instance = factory.CreateInstance(provider); // Assert Assert.NotNull(instance); Assert.IsType <TestFilter>(instance); }