示例#1
0
        public void SimpleClassAsT()
        {
            var dumbContainer = new DumbContainer();

            dumbContainer.Register <TestClass, TestClass>();
            dumbContainer.Register <InnerTestClass, InnerTestClass>();

            var resolve = dumbContainer.Resolve <TestClass>();

            resolve.Should().NotBeNull();
            resolve.Should().BeOfType <TestClass>();

            resolve.InnerTest.Should().NotBeNull();
            resolve.InnerTest.Should().BeOfType <InnerTestClass>();
        }
示例#2
0
        public void SimpleClassAsT()
        {
            var dumbContainer = new DumbContainer();

            Action register = () => dumbContainer.Register <ITestClass, TestClass>();

            register.Should().NotThrow();
        }
        public void SimpleClassAsT()
        {
            var dumbContainer = new DumbContainer();

            dumbContainer.Register <TestClass, TestClass>();

            Action action = () => dumbContainer.Resolve <ITestClass>();

            action.Should().Throw <TryToResolveNotRegisteredTypeException>();
        }
        public void SimpleClass()
        {
            var dumbContainer = new DumbContainer();

            var testClassType = typeof(TestClass);

            Action register = () => dumbContainer.Register(testClassType, testClassType);

            register.Should().NotThrow();
        }
        public void SimpleClass()
        {
            var dumbContainer = new DumbContainer();

            var testClassType = typeof(TestClass);

            var innerTestClassType = typeof(InnerTestClass);

            dumbContainer.Register(testClassType, testClassType);
            dumbContainer.Register(innerTestClassType, innerTestClassType);

            var resolve = dumbContainer.Resolve(testClassType);

            resolve.Should().NotBeNull();
            resolve.Should().BeOfType(testClassType);

            TestClass testClass = (TestClass)resolve;

            testClass.InnerTest.Should().NotBeNull();
            testClass.InnerTest.Should().BeOfType(innerTestClassType);
        }
        public void SimpleClassAsT()
        {
            var dumbContainer = new DumbContainer();

            var testClassType = typeof(TestClass);

            dumbContainer.Register(testClassType, testClassType);

            object resolve = dumbContainer.Resolve <TestClass>();

            resolve.Should().NotBeNull();
            resolve.Should().BeOfType(testClassType);
        }
        public void SimpleClass()
        {
            var dumbContainer = new DumbContainer();

            var interfaceType = typeof(ITestClass);
            var testClassType = typeof(TestClass);

            var innerInterfaceType = typeof(IInnerTestClass);
            var innerTestClassType = typeof(InnerTestClass);

            dumbContainer.Register(interfaceType, testClassType);
            dumbContainer.Register(innerInterfaceType, innerTestClassType);

            var resolve = dumbContainer.Resolve(interfaceType);

            resolve.Should().NotBeNull();
            resolve.Should().BeAssignableTo(interfaceType);

            ITestClass testClass = (ITestClass)resolve;

            testClass.InnerTest.Should().NotBeNull();
            testClass.InnerTest.Should().BeAssignableTo(innerInterfaceType);
        }