示例#1
0
 public void DefaultApiBaseCanBeCreatedAndDisposed()
 {
     using (var api = new TestApi())
     {
         api.Dispose();
     }
 }
示例#2
0
 public void DefaultApiBaseCanBeCreatedAndDisposed()
 {
     using (var api = new TestApi())
     {
         api.Dispose();
     }
 }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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);
        }
示例#6
0
 public override void Dispose()
 {
     base.Dispose();
     TestApi.Dispose();
     IdentityProvider.Dispose();
 }
示例#7
0
 public void Dispose()
 {
     _api.Dispose();
 }