public void GetServicesGeneric()
        {
            IContainerBuilder builder = new TestContainerBuilder();

            builder.AddService <IFoo, Foo>(ServiceLifetime.Transient);
            builder.AddService <IFoo, Bar>(ServiceLifetime.Transient);
            IServiceProvider container = builder.BuildContainer();

            Assert.Equal(2, container.GetServices <IFoo>().Count());
        }
        public void GetRequiredServiceNonGeneric()
        {
            IContainerBuilder builder = new TestContainerBuilder();

            builder.AddService(ServiceLifetime.Transient, typeof(Foo));
            IServiceProvider container = builder.BuildContainer();

            Assert.NotNull(container.GetRequiredService(typeof(Foo)));
        }
        public void GetNonExistingRequiredServiceThrows()
        {
            IContainerBuilder builder = new TestContainerBuilder();

            builder.AddService(ServiceLifetime.Transient, typeof(Foo));
            IServiceProvider container = builder.BuildContainer();

            Assert.Throws(typeof(ODataException), () => container.GetRequiredService <IFoo>());
        }
        public void GetNonExistingServiceGeneric()
        {
            IContainerBuilder builder = new TestContainerBuilder();

            builder.AddService(ServiceLifetime.Transient, typeof(Foo));
            IServiceProvider container = builder.BuildContainer();

            Assert.Null(container.GetService <IFoo>());
        }
        public void AddServiceWithTServiceAndTImplementationFactory()
        {
            IContainerBuilder builder = new TestContainerBuilder();

            builder.AddService <IFoo>(ServiceLifetime.Transient, sp => new Foo());
            IServiceProvider container = builder.BuildContainer();

            Assert.NotNull(container.GetService <IFoo>());
        }
        public void AddServiceWithTServiceOnly()
        {
            IContainerBuilder builder = new TestContainerBuilder();

            builder.AddService <Foo>(ServiceLifetime.Transient);
            IServiceProvider container = builder.BuildContainer();

            Assert.NotNull(container.GetService <Foo>());
        }
        public void AddServiceWithServiceType()
        {
            IContainerBuilder builder = new TestContainerBuilder();

            builder.AddService(ServiceLifetime.Transient, typeof(Foo));
            IServiceProvider container = builder.BuildContainer();

            Assert.NotNull(container.GetService <Foo>());
        }