Example #1
0
        public void Should_throw_ArgumentException_if_provided_name_is_null()
        {
            var mockDependencyResolver = new Mock<IDependencyResolver>();
            var directory = new DefaultDirectory<object>(mockDependencyResolver.Object);

            Assert.Throws<ArgumentException>(() => { var obj = directory[null]; });
        }
Example #2
0
        public void Should_return_null_if_named_instance_is_not_found()
        {
            const string testObjName = "Test";

            var mockDependencyResolver = new Mock<IDependencyResolver>();
            var directory = new DefaultDirectory<object>(mockDependencyResolver.Object);

            mockDependencyResolver.Setup(dr => dr.Get<object>(testObjName)).Returns(null);

            var obj = directory[testObjName];

            Assert.IsNull(obj);
        }