Beispiel #1
0
        public void DependencyCollisionTest()
        {
            InvertContainer container = new InvertContainer();

            container.Register <MockDependency>();

            Assert.Throws <DependencyCollisionException>(() => { container.Register <MockDependency>(); });
        }
Beispiel #2
0
        public void NestedDependencyResolveTest()
        {
            InvertContainer container = new InvertContainer();

            container.Register <MockParentDependency>();
            container.Register <MockChildDependency>();

            Assert.NotNull(container.Resolve <MockParentDependency>());
        }
Beispiel #3
0
        public void DependencyWithNoConstructorTest()
        {
            InvertContainer container = new InvertContainer();

            container.Register <BadMockDependency>();

            Assert.Throws <MissingMethodException>(() => { container.Resolve <BadMockDependency>(); });
        }
Beispiel #4
0
        public void RegisterInterfaceDependencyTest()
        {
            InvertContainer container = new InvertContainer();

            container.Register <IMockDependency>().To <MockDependency>();

            Assert.True(container.HasDependency <IMockDependency>());
        }
Beispiel #5
0
        public void NestedDependencyMissingResolveTest()
        {
            InvertContainer container = new InvertContainer();

            container.Register <MockParentDependency>();

            Assert.Throws <DependencyNotFoundException>(() => { container.Resolve <MockParentDependency>(); });
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            InvertContainer container = new InvertContainer();

            container.Register <IFoo>().To <Foo>();

            Console.WriteLine(container.Resolve <IFoo>());

            Console.ReadKey();
        }
Beispiel #7
0
        public void InstanceResolveTest()
        {
            InvertContainer container = new InvertContainer();

            container.Register <MockDependency>();

            MockDependency dependency1 = container.Resolve <MockDependency>();
            MockDependency dependency2 = container.Resolve <MockDependency>();

            Assert.NotSame(dependency1, dependency2);
        }
Beispiel #8
0
        public void SingletonResolveTest()
        {
            InvertContainer container = new InvertContainer();

            container.Register <MockDependency>().Singleton();

            MockDependency dependency1 = container.Resolve <MockDependency>();
            MockDependency dependency2 = container.Resolve <MockDependency>();

            Assert.Same(dependency1, dependency2);
        }