GetService() public method

public GetService ( Type serviceType ) : object
serviceType System.Type
return object
        public void GetService_WithNoRegistration_ReturnsNull() {
            // arrange
            var builder = new ContainerBuilder();
            var container = builder.Build();
            var resolver = new AutofacDependencyResolver(container);

            // act
            var entity = resolver.GetService(typeof(ISomeType));

            Assert.Null(entity);
        }
        public void GetService_WithNoRegistrations_ReturnsDefaultValue() {
            // arrange
            var builder = new ContainerBuilder();
            var container = builder.Build();
            var resolver = new AutofacDependencyResolver(container);

            // act
            var entity = resolver.GetService(typeof(ISomeType));

            Assert.Equal(default(ISomeType), entity);
        }
        public void GetService_WithSingleRegistration_ReturnsNotNull() {
            // arrange
            var builder = new ContainerBuilder();
            builder.RegisterType<SimpleType>().AsImplementedInterfaces();
            var container = builder.Build();
            var resolver = new AutofacDependencyResolver(container);

            // act
            var entity = resolver.GetService(typeof(ISomeType));

            Assert.NotNull(entity);
        }
        public void Register_WithOneFunc_ReturnsDistinctItemsEachTime() {
            // arrange
            var builder = new ContainerBuilder();
            var container = builder.Build();
            var resolver = new AutofacDependencyResolver(container);
            
            // act
            resolver.Register(typeof(ISomeType), () => new SimpleType());
            var firstSet = resolver.GetService(typeof(ISomeType));
            var secondSet = resolver.GetService(typeof(ISomeType));

            Assert.NotSame(firstSet, secondSet);
        }
        public void Register_WithOneFunc_ReturnsNotNullResult() {
            // arrange
            var builder = new ContainerBuilder();
            var container = builder.Build();
            var resolver = new AutofacDependencyResolver(container);

            // act
            resolver.Register(typeof(ISomeType), () => new SimpleType());
            var result = resolver.GetService(typeof(ISomeType));

            Assert.NotNull(result);
        }