public void GetSingleService() { var service = new Class1(); var container = new Mock <IContainer>(); container.Setup(c => c.GetService(typeof(IInterface1))) .Returns(service); var scope = new AutoPocoDependencyScope(container.Object); var result = scope.GetService(typeof(IInterface1)); Assert.AreEqual(service, result); }
public void PassContainerFromOwinToRequest() { var handler = new PublicHandler(); var request = new HttpRequestMessage(); var container = new Mock <IContainer>(); container.Setup(c => c.GetService(typeof(Class1))) .Returns("container"); var owinContext = new OwinContext(); owinContext.Set("autopoco:container", container.Object); request.Properties["MS_OwinContext"] = owinContext; handler.SendAsyncPublic(request).Wait(); AutoPocoDependencyScope result = (AutoPocoDependencyScope)request.Properties[HttpPropertyKeys.DependencyScope]; Assert.AreEqual("container", result.GetService(typeof(Class1))); }