예제 #1
0
        public void GetSingletonInstance()
        {
            var services = new ServiceCollection();

            services.AddSingleton <IService1>(new Service1());
            services.GetSingletonInstance <IService1>().ShouldBeOfType <Service1>().ShouldNotBeNull();
            Should.Throw <InvalidOperationException>(() => services.GetSingletonInstance <IService2>());
        }