public void TestSimplePropertiesBuildup()
        {
            var container = new CryoContainer();

            container.RegisterInstance("private base", "PrivateBase");
            container.RegisterInstance("protected base", "ProtectedBase");
            container.RegisterInstance("public base", "PublicBase");

            var a = new ClassBase();

            container.BuildUp(a);
            a.Check();
        }
        public void TestSimplePropertiesResolve()
        {
            var container = new CryoContainer();

            container.RegisterInstance("private base", "PrivateBase");
            container.RegisterInstance("protected base", "ProtectedBase");
            container.RegisterInstance("public base", "PublicBase");
            container.RegisterType <ClassBase>();


            var a = container.Resolve <ClassBase>();

            a.Check();
        }
Beispiel #3
0
        private static void CreateContainer()
        {
            _container = new CryoContainer();
            _container.RegisterSingleton <SingletonCounter>(GlobalSingleton, LifeTime.Global);
            _container.RegisterSingleton <SingletonCounter>(SceneSingleton, LifeTime.Scene);
            _container.RegisterSingleton <SingletonCounter>(ExternalSingleton, LifeTime.External);

            _container.RegisterType <TypeCounter>(GlobalType, LifeTime.Global);
            _container.RegisterType <TypeCounter>(SceneType, LifeTime.Scene);
            _container.RegisterType <TypeCounter>(ExternalType, LifeTime.External);

            _container.RegisterInstance(new InstanceCounter(), GlobalInstance, LifeTime.Global);
            _container.RegisterInstance(new InstanceCounter(), SceneInstance, LifeTime.Scene);
            _container.RegisterInstance(new InstanceCounter(), ExternalInstance, LifeTime.External);
        }
    public void OnSetup()
    {
        var container = new CryoContainer();

        container.RegisterInstance(new Mock <IErrorMessageController>().Object);
        container.RegisterSingleton <IPathfindingAlgorithm, AstarAlgorithm>();

        _pathfindingAlgorithm = container.Resolve <IPathfindingAlgorithm>();
    }
Beispiel #5
0
        public void TestInstance()
        {
            var container = new CryoContainer();
            var myClazz   = new MyClazz();

            container.RegisterInstance(myClazz);

            var myClazz2 = container.TryResolve <MyClazz>();

            Assert.IsNotNull(myClazz2);
            Assert.AreSame(myClazz, myClazz2);
        }
Beispiel #6
0
    protected override void SetupContainer(CryoContainer container)
    {
        base.SetupContainer(container);

        var colorDatabase = ColorDatabaseLoader.LoadDatabase();

        container.RegisterInstance <IColorDatabase>(colorDatabase, LifeTime.Global);

        container.RegisterSingleton <IPathfindingAlgorithm, AstarAlgorithm>(LifeTime.Scene);

        container.RegisterSingleton <IErrorMessageFactory, ErrorMessageFactory>(LifeTime.Global);
        container.RegisterSingleton <IErrorMessageController, ErrorMessageController>(LifeTime.Global);

        container.RegisterSceneObject <UIGridView>(LifeTime.Scene);
    }
Beispiel #7
0
        public void TestInstance()
        {
            var instance = new MainClass();

            var container = new CryoContainer();

            container.RegisterInstance(instance);

            container.RegisterAlias <IFirstInterface, MainClass>();
            container.RegisterAlias <ISecondInterface, MainClass>();

            var firstInterface  = container.Resolve <IFirstInterface>();
            var secondInterface = container.Resolve <ISecondInterface>();

            Assert.AreSame(instance, firstInterface);
            Assert.AreSame(instance, secondInterface);
        }
        public void TestDerivedPropertiesBuildup()
        {
            var container = new CryoContainer();

            container.RegisterInstance("private base", "PrivateBase");
            container.RegisterInstance("protected base", "ProtectedBase");
            container.RegisterInstance("public base", "PublicBase");

            container.RegisterInstance("private derived", "PrivateDerived");
            container.RegisterInstance("protected derived", "ProtectedDerived");
            container.RegisterInstance("public derived", "PublicDerived");

            var a = new ClassDerived();

            container.BuildUp(a);
            a.Check();
        }
        public void TestDerivedPropertiesResolve()
        {
            var container = new CryoContainer();

            container.RegisterInstance("private base", "PrivateBase");
            container.RegisterInstance("protected base", "ProtectedBase");
            container.RegisterInstance("public base", "PublicBase");

            container.RegisterInstance("private derived", "PrivateDerived");
            container.RegisterInstance("protected derived", "ProtectedDerived");
            container.RegisterInstance("public derived", "PublicDerived");
            container.RegisterType <ClassDerived>();

            var a = container.Resolve <ClassDerived>();

            a.Check();
        }