Ejemplo n.º 1
0
        public void Should_Not_Resolve_Service_Dependency()
        {
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            Assert.Throws <InvalidOperationException>(() => engine.Resolve <ITransientService>());
        }
Ejemplo n.º 2
0
        public void Should_Resolve_Unregistered_Service_Dependency()
        {
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            var requiredService = engine.ResolveUnregistered(typeof(UnregisteredService));

            Assert.NotNull(requiredService);
        }
Ejemplo n.º 3
0
        public void Should_Resolve_Service_Dependency()
        {
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService));
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            var requiredService = engine.Resolve <ITransientService>();

            Assert.NotNull(requiredService);
        }
Ejemplo n.º 4
0
        public void Should_Resolve_All_Service_Dependency()
        {
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService));
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService1));
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            var requiredService = engine.ResolveAll <ITransientService>();

            Assert.Equal(2, requiredService.Count());
        }
Ejemplo n.º 5
0
        public void Should_Register_Service_Dependency()
        {
            Collection.AddSingleton(typeof(ITransientService), typeof(TransientService));
            var engine = new CoreEngine(Collection);

            engine.ConfigureServices();

            using (var serviceScope = engine.ServiceProvider.CreateScope())
            {
                var requiredService = serviceScope.ServiceProvider.GetService <ITransientService>();

                Assert.NotNull(requiredService);
            }
        }