Example #1
0
        public void should_not_get_service_if_type_not_exist()
        {
            var controllerTypeResolver = new DefaultHttpControllerTypeResolver();
            var resolver = new DefaultDependencyResolver(controllerTypeResolver.GetControllerTypes(ControllerAssemblies));

            Assert.Null(resolver.GetService(typeof(NotExistedType)));
        }
Example #2
0
        public void should_get_service_if_type_exist()
        {
            var controllerTypeResolver = new DefaultHttpControllerTypeResolver();
            var resolver = new DefaultDependencyResolver(controllerTypeResolver.GetControllerTypes(ControllerAssemblies));

            Assert.Equal(
                typeof(ControllerWithoutAction),
                resolver.GetService(typeof(ControllerWithoutAction)).GetType());
        }
Example #3
0
        public void RegisterType_WithDependency_Resolves()
        {
            // Arrange
            var resolver = new DefaultDependencyResolver();

            resolver.Register <IDisposable, Instance>();

            // Act
            var result = resolver.GetService <TypeWithDependency>(null);

            // Assert
            Assert.NotNull(result.Dependency);
        }
Example #4
0
        public void RegisterType_ReturnsNewInstance()
        {
            // Arrange
            var resolver = new DefaultDependencyResolver();

            resolver.Register <IDisposable, Instance>();

            // Act
            var result = resolver.GetService <IDisposable>(null);

            // Assert
            Assert.NotNull(result);
        }
Example #5
0
        public void RegisterInstance_ByInterface_ReturnsInstance()
        {
            // Arrange
            var resolver = new DefaultDependencyResolver();
            var value    = new Instance();

            resolver.Register <IDisposable>(value, null);

            // Act
            var result = resolver.GetService <IDisposable>(null);

            // Assert
            Assert.Equal(value, result);
        }