public void Multiple_type_registrations_should_support_named_build_test()
        {
            var container = new DIContainer();

            container
            .Register <IX, X>("x")
            .Register <IX, XAlt>("xalt");
            container.Build <IX>("x").Should().BeOfType <X>();
            container.Build <IX>("xalt").Should().BeOfType <XAlt>();
        }
        public void Building_non_registered_contract_type_should_throw()
        {
            var    container = new DIContainer();
            Action create    = () => container.Build(typeof(IX));

            create.Should().Throw <DIContainerException>();
        }
        public void Building_non_registered_concrete_type_should_create_instance_test()
        {
            var container = new DIContainer();
            var x         = container.Build(typeof(X)) as X;

            x.Should().NotBeNull();
        }
        public void Resolve_via_default_constructor_test()
        {
            var container = new DIContainer();

            container.Register(typeof(IX), typeof(X));
            var x = container.Build(typeof(IX));

            x.Should().NotBeNull();
        }
        public void Basic_property_injection_test()
        {
            var container = new DIContainer();

            container
            .Register <IX, XWithProperty>()
            .Register <IY, Y>();
            var x = container.Build <IX>() as XWithProperty;

            x.Should().NotBeNull();
            x.Y.Should().NotBeNull();
        }
        public void Property_injection_should_only_inject_attributed_properties()
        {
            var container = new DIContainer();

            container
            .Register <IX, XWithMultipleProperties>()
            .Register <IY, Y>();
            var x = container.Build <IX>() as XWithMultipleProperties;

            x.Should().NotBeNull();
            x.Y1.Should().NotBeNull();
            x.Y2.Should().BeNull();
        }
예제 #7
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            //DI setup
            DIContainer.Init();
            DIContainer.Build();

            // create a new window instance based on the screen size
            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            Window.RootViewController = new UIViewController();

            // make the window visible
            Window.MakeKeyAndVisible();

            return(true);
        }