public void add_singleton_service()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceA a = new ServiceA();
            c.AddService(typeof(ServiceA), a);

            Assert.That(c.GetService<ServiceA>(), Is.SameAs(a));
        }
        public void dedupe_by_name_services()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceA a1 = new ServiceA();
            c.AddService("hello", a1);
            c.AddService("other", a1);

            Assert.That(c.GetServices<ServiceA>().Count(), Is.EqualTo(1));
        }
        public void apply_polymorphism_to_services()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceB b = new ServiceB();
            ServiceC d = new ServiceC();
            c.AddService(typeof(ServiceB), b);
            c.AddService(typeof(ServiceC), d);

            Assert.That(c.GetServices<ServiceB>().Count(), Is.EqualTo(2));
            Assert.That(c.GetServices<ServiceB>(), Contains.Item(d));
        }
        public void add_multiple_services()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceA a1 = new ServiceA();
            ServiceA a2 = new ServiceA();
            c.AddService(typeof(ServiceA), a1);
            c.AddService("other", a2);

            Assert.That(c.GetServices<ServiceA>(), Contains.Item(a1));
            Assert.That(c.GetServices<ServiceA>(), Contains.Item(a2));
        }
        public void dedupe_by_type_services_polymorphic()
        {
            FrameworkServiceContainer c = new FrameworkServiceContainer();
            ServiceC d = new ServiceC();
            c.AddService(typeof(ServiceB), d);
            c.AddService(typeof(ServiceC), d);

            Assert.That(c.GetServices<ServiceB>().Count(), Is.EqualTo(1));
        }
 public void obtains_service_container_trivially()
 {
     FrameworkServiceContainer c = new FrameworkServiceContainer();
     Assert.That(c.GetService(typeof(IServiceContainer)), Is.SameAs(c));
     Assert.That(c.GetService(typeof(IServiceProvider)), Is.SameAs(c));
     Assert.That(c.GetService(typeof(IServiceProviderExtension)), Is.SameAs(c));
 }