public void UseAutofacMiddlewareAddsWrappedMiddlewareInstancesToAppBuilder() { var builder = new ContainerBuilder(); builder.RegisterType <TestMiddleware>(); var container = builder.Build(); var app = new Mock <IAppBuilder>(); app.Setup(mock => mock.Properties).Returns(new Dictionary <string, object>()); app.Setup(mock => mock.Use(typeof(AutofacMiddleware <TestMiddleware>))); OwinExtensions.UseAutofacMiddleware(app.Object, container); app.VerifyAll(); }
public static DotvvmConfiguration InitDotVVM(Assembly webSiteAssembly, string rootPath) { var dotvvmStartups = webSiteAssembly.GetLoadableTypes() .Where(t => typeof(IDotvvmStartup).IsAssignableFrom(t) && t.GetConstructor(Type.EmptyTypes) != null).ToArray(); if (dotvvmStartups.Length == 0) { throw new Exception("Could not find any implementation of IDotvvmStartup."); } if (dotvvmStartups.Length > 1) { throw new Exception($"Found more than one implementation of IDotvvmStartup ({string.Join(", ", dotvvmStartups.Select(s => s.Name)) })."); } var startup = (IDotvvmStartup)Activator.CreateInstance(dotvvmStartups[0]); var config = OwinExtensions.CreateConfiguration(rootPath); startup.Configure(config, rootPath); config.CompiledViewsAssemblies = null; return(config); }
public void GetAutofacLifetimeScopeThrowsWhenProvidedNullInstance() { var exception = Assert.Throws <ArgumentNullException>(() => OwinExtensions.GetAutofacLifetimeScope(null)); Assert.That(exception.ParamName, Is.EqualTo("context")); }
public static IAppBuilder RunSignalR(this IAppBuilder builder) { OwinExtensions.RunSignalR(builder); return(builder); }