public void GetStartResource_MockRootFactory_CallsGetStartResource() { var rootFactoryMock = new Mock <IRootResourceFactory>(); var services = new TestStemsServices(); var factory = new StemsStartResourceFactory { StemsServices = services, RootResourceFactory = rootFactoryMock.Object }; var context = new TestRequestContext(); var startResource = factory.GetStartResource(context); rootFactoryMock.Verify(f => f.GetStartResource(services, context)); }
public void DisposeEndpointContextDisposesStem() { var endpointContext = new TestRequestContext(); var stemStartResources = new StemsStartResourceFactory { RootResourceFactory = new DerivedRootsResourceFactory { RootTypeGetter = new ManualTypeGetter(typeof(DisposableRoot)) }, StemsServices = new StemsServices { ServiceGroup = new DefaultServiceGroup() } }; var directory = (IRestDirectory)stemStartResources.GetStartResource(endpointContext); var collection = directory.GetChild("Disposable"); DisposableRoot.DisposeCalled = false; endpointContext.Dispose(); Assert.True(DisposableRoot.DisposeCalled); }
private IRestDirectory GetDirectoryFromRoots(params Type[] rootTypes) { TestDependencyResolver.Add(TestRepository); var stemStartResources = new StemsStartResourceFactory { RootResourceFactory = new DerivedRootsResourceFactory { RootTypeGetter = new ManualTypeGetter(rootTypes) }, StemsServices = new StemsServices { DependencyResolver = TestDependencyResolver, ServiceGroup = new DefaultServiceGroup(), AutoPropertyMapper = new DefaultPropertyAutoMapper() } }; stemStartResources.Initialize(); var directory = (IRestDirectory)stemStartResources.GetStartResource(new TestRequestContext()); return(directory); }