コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }