JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com
MIT License
294 stars 50 forks source link

HowTo BeforeServiceProviderBuild #160

Closed sparkitny closed 4 years ago

sparkitny commented 4 years ago

Hi,

I just tried to fix the issue with AbstractAcceptanceTest by inserting an ILogger with the method BeforeServiceProviderBuild, but I can't figure out how to accomplish this.

When I try to override the method, it complains that this method needs to be marked as [Theory], but if I mark it as [Theory], it complains that Theory methods must have test data.

I just looked for an expample, but I can't find one. Can anyone help out?

sparkitny commented 4 years ago

I figured out how to implement BeforeServiceProviderBuild

        [Theory]
        [InlineData(null, null)]
        public override void BeforeServiceProviderBuild(IServiceCollection serviceCollection, ICommandRegistry commandRegistry)
        {
            base.BeforeServiceProviderBuild(serviceCollection, commandRegistry);

            serviceCollection.AddTransient<ILogger>(c => c.GetRequiredService<ILoggerFactory>().CreateLogger("test"));
        }

69 unfortunately is not fixed in release 3.0.17