public IWebHost ValidateListenerBuilder(TContext context, KestrelListenerBuilder <MockStartup, TService, TContext> builder) { Assert.AreEqual(ListenerName, builder.Name); IWebHost host = builder.BuildWebHost( string.Empty, new MockListener(context, (s, l) => new Mock <IWebHost>().Object)); ResolveType <IAccessor <TContext> >(host); ResolveType <IAccessor <ServiceContext> >(host); ResolveType <IAccessor <IServicePartition> >(host); bool isStatefulService = typeof(StatefulServiceContext).IsAssignableFrom(typeof(TContext)); if (isStatefulService) { ResolveType <IAccessor <IReliableStateManager> >(host); ResolveType <IAccessor <IStatefulServicePartition> >(host); } else { ResolveType <IAccessor <IStatelessServicePartition> >(host); } ResolveType <TypeRegisteredInListenerExtension>(host); ResolveType <MockStartup.TypeRegisteredInStartup>(host); return(host); }
public ICommunicationListener ValidateBuildFunction(TService service, KestrelListenerBuilder <MockStartup, TService, TContext> builder) { ICommunicationListener listener = builder.Build(service); Assert.IsNotNull(listener, "Listener should not be null"); return(listener); }
private void CheckTypeRegistration <TService, TContext>( TService service, Func <ListenerValidator <TService, TContext>, IHostBuilder, IHost> buildAction) where TService : IServiceFabricService <TContext> where TContext : ServiceContext { ListenerValidator <TService, TContext> validator = new ListenerValidator <TService, TContext>(); IHostBuilder hostBuilder = new HostBuilder() .UseDefaultServiceProvider(options => { options.ValidateOnBuild = true; options.ValidateScopes = true; }); IHost host = buildAction(validator, hostBuilder); IListenerBuilder <TService> builder = host.Services.GetService <IListenerBuilder <TService> >(); Assert.IsNotNull(builder); KestrelListenerBuilder <MockStartup, TService, TContext> kestrelBuilder = (KestrelListenerBuilder <MockStartup, TService, TContext>)builder; IWebHost webHost = validator.ValidateListenerBuilder(service.Context, kestrelBuilder); validator.ValidateOmexTypesRegistered(webHost); validator.ValidateBuildFunction(service, kestrelBuilder); }
private void CheckTypeRegistration <TService, TContext>(TService service) where TService : IServiceFabricService <TContext> where TContext : ServiceContext { ListenerValidator <TService, TContext> validator = new ListenerValidator <TService, TContext>(); KestrelListenerBuilder <MockStartup, TService, TContext> builder = new KestrelListenerBuilder <MockStartup, TService, TContext>( validator.ListenerName, validator.IntegrationOptions, validator.BuilderAction); validator.ValidateListenerBuilder(service.Context, builder); validator.ValidateBuildFunction(service, builder); }
public IWebHost ValidateListenerBuilder(TContext context, KestrelListenerBuilder <MockStartup, TService, TContext> builder) { Assert.AreEqual(ListenerName, builder.Name); IWebHost host = builder.BuildWebHost( context, string.Empty, new MockListener(context, (s, l) => new Mock <IWebHost>().Object)); Assert.AreEqual(context, ResolveType <ServiceContext>(host)); Assert.AreEqual(context, ResolveType <TContext>(host)); Assert.AreEqual(context, ResolveType <IAccessor <TContext> >(host).Value); ResolveType <TypeRegisteredInListenerExtension>(host); ResolveType <MockStartup.TypeRegisteredInStartup>(host); return(host); }
private void CheckTypeRegistration <TService, TContext>(TService service) where TService : IServiceFabricService <TContext> where TContext : ServiceContext { ListenerValidator <TService, TContext> validator = new ListenerValidator <TService, TContext>(); ServiceProvider serviceProvider = new ServiceCollection() .AddOmexServiceFabricDependencies <TContext>() .BuildServiceProvider(); KestrelListenerBuilder <MockStartup, TService, TContext> builder = new KestrelListenerBuilder <MockStartup, TService, TContext>( validator.ListenerName, serviceProvider, validator.IntegrationOptions, validator.BuilderAction, validator.KestrelOptionsAction); IWebHost host = validator.ValidateListenerBuilder(service.Context, builder); validator.ValidateBuildFunction(service, builder); validator.ValidateKestrelServerOptionsSet(host); }