Exemplo n.º 1
0
 public void DefaultApiBaseCanBeCreatedAndDisposed()
 {
     using (var api = new TestApi())
     {
         api.Dispose();
     }
 }
Exemplo n.º 2
0
 public void DefaultApiBaseCanBeCreatedAndDisposed()
 {
     using (var api = new TestApi())
     {
         api.Dispose();
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
 public override void Dispose()
 {
     base.Dispose();
     TestApi.Dispose();
     IdentityProvider.Dispose();
 }
Exemplo n.º 7
0
 public void Dispose()
 {
     _api.Dispose();
 }