コード例 #1
0
        public void ExtensionReturnsTrueIfThereIsAPolicyForType()
        {
            UnityContainer container = new UnityContainer();
            container.AddNewExtension<UnityBootstrapperExtension>();

            container.RegisterType<object, string>();
            Assert.IsTrue(container.IsTypeRegistered(typeof(object)));
            Assert.IsFalse(container.IsTypeRegistered(typeof(int)));

            container.RegisterType<IList<int>, List<int>>();

            Assert.IsTrue(container.IsTypeRegistered(typeof(IList<int>)));
            Assert.IsFalse(container.IsTypeRegistered(typeof(IList<string>)));

            container.RegisterType(typeof(IDictionary<,>), typeof(Dictionary<,>));
            Assert.IsTrue(container.IsTypeRegistered(typeof(IDictionary<,>)));
        }