コード例 #1
0
        public void LiteContainer_RegisterConcreteTypeTwice_ThrowsInvalidOperationException()
        {
            var c = new LiteContainer();

            c.Register(() => new Number(2));

            AssertThrowsExceptionOfType <InvalidOperationException>(() => c.Register(() => new Number(3)));
        }
コード例 #2
0
        public void LiteContainer_ResolveTypeAsInterface_CanResolveType()
        {
            var c = new LiteContainer();

            c.Register <Person>(() => new Student("Jim"));

            var instance = c.Resolve <Person>();

            Assert.AreEqual("Jim", instance.Name);
        }
コード例 #3
0
        public void LiteContainer_ResolveConcreteRegisteredType_TypeIsCorrect()
        {
            var c = new LiteContainer();

            c.Register(() => new Number(2));

            var instance = c.Resolve <Number>();

            Assert.AreEqual(2, instance.Value);
        }