Beispiel #1
0
        public void Get_ByType_Disposed()
        {
            var dependencyService = new DependencyBuilder().Build().CreateScope();

            dependencyService.Dispose();

            Assert.Throws <ObjectDisposedException>(() => dependencyService.Get(typeof(IFirst)));
        }
Beispiel #2
0
        public void Get_Disposed()
        {
            var dependencyService = new DependencyBuilder().Build();

            dependencyService.Dispose();

            Assert.Throws <ObjectDisposedException>(() => dependencyService.Get <IFirst>());
        }
Beispiel #3
0
        public void Dispose_Success_DisposableScoped_SuppressesExceptions()
        {
            var dependencyService =
                new DependencyBuilder()
                .EnableServiceAutoDetection(GetType().Assembly)
                .AddScoped <IFirst, First.RequiresNone>()
                .Build().CreateScope();

            var service = dependencyService.Get <IFirst>();

            Assert.NotNull(service);
            var first = Assert.IsType <First.RequiresNone>(service);

            first.Dispose();

            dependencyService.Dispose();
        }
Beispiel #4
0
        public void Dispose_Success_DisposableSingleton()
        {
            var dependencyService =
                new DependencyBuilder()
                .EnableServiceAutoDetection(GetType().Assembly)
                .AddSingleton <IFirst, First.RequiresNone>()
                .Build();

            var service = dependencyService.Get <IFirst>();

            Assert.NotNull(service);
            var first = Assert.IsType <First.RequiresNone>(service);

            dependencyService.Dispose();

            Assert.True(first.IsDisposed);
        }