private static Thing ConfigureThing <T>(IServiceProvider provider) where T : Thing { var thing = provider.GetRequiredService <T>(); var option = provider.GetRequiredService <ThingOption>(); var optionsJson = new JsonSerializerOptions { WriteIndented = false, IgnoreNullValues = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; var converter = new ConverterInterceptorFactory(thing, optionsJson); var properties = new PropertiesInterceptFactory(thing, option); var events = new EventInterceptFactory(thing, option); var actions = new ActionInterceptFactory(option); CodeGeneratorFactory.Generate(thing, new List <IInterceptorFactory>() { converter, properties, events, actions }); thing.ThingContext = new Context(converter.Create(), properties.Create(), events.Events, actions.Actions); return(thing); }
public ActionInterceptFactoryTest() { _fixture = new Fixture(); _thing = new LampThing(); _factory = new ActionInterceptFactory(new ThingOption()); var logger = Substitute.For <ILogger <ActionInfo> >(); _provider = Substitute.For <IServiceProvider>(); _provider.GetService(typeof(ILogger <ActionInfo>)) .Returns(logger); }