Exemple #1
0
        public void TestType()
        {
            var container = new CryoContainer();

            container.RegisterType <MyClazz>();

            Assert.IsNull(container.TryResolve <MyClazz>());
            var clazz = container.Resolve <MyClazz>();

            Assert.IsNotNull(clazz);
            Assert.IsNull(container.TryResolve <MyClazz>());
        }
Exemple #2
0
        public void TestSingleton()
        {
            var container = new CryoContainer();

            container.RegisterSingleton <MyClazz>();

            Assert.IsNull(container.TryResolve <MyClazz>());
            var clazz = container.Resolve <MyClazz>();

            Assert.IsNotNull(clazz);

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

            Assert.IsNotNull(clazz2);
            Assert.AreSame(clazz, clazz2);
        }
Exemple #3
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);
        }