public void DefaultApiBaseCanBeCreatedAndDisposed() { using (var api = new TestApi()) { api.Dispose(); } }
public void ApiAndApiContextCanBeInjectedByDI() { using (var api = new TestApi()) { var context = api.Context; var svc = context.GetApiService<IService>(); Assert.Same(svc.Api, api); Assert.Same(svc.Context, context); api.Dispose(); Assert.Throws<ObjectDisposedException>(() => api.Context); } }
public void ApiAndApiContextCanBeInjectedByDI() { using (var api = new TestApi()) { var context = api.Context; var svc = context.GetApiService <IService>(); Assert.Same(svc.Api, api); Assert.Same(svc.Context, context); api.Dispose(); Assert.Throws <ObjectDisposedException>(() => api.Context); } }
public void PropertyBagsAreDisposedCorrectly() { var api = new TestApi(); var context = api.Context; var configuration = context.Configuration; Assert.NotNull(configuration.GetApiService <MyPropertyBag>()); Assert.Equal(1, MyPropertyBag.InstanceCount); Assert.NotNull(context.GetApiService <MyPropertyBag>()); Assert.Equal(2, MyPropertyBag.InstanceCount); // This will dispose all the scoped and transient instances registered // in the ApiContext scope. api.Dispose(); // The one in ApiConfiguration will NOT be disposed until the service ends. Assert.Equal(1, MyPropertyBag.InstanceCount); }
public override void Dispose() { base.Dispose(); TestApi.Dispose(); IdentityProvider.Dispose(); }
public void Dispose() { _api.Dispose(); }