public void InstanceResolveTest() { InvertContainer container = new InvertContainer(); container.Register <MockDependency>(); MockDependency dependency1 = container.Resolve <MockDependency>(); MockDependency dependency2 = container.Resolve <MockDependency>(); Assert.NotSame(dependency1, dependency2); }
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); }
public void DependencyWithNoConstructorTest() { InvertContainer container = new InvertContainer(); container.Register <BadMockDependency>(); Assert.Throws <MissingMethodException>(() => { container.Resolve <BadMockDependency>(); }); }
public void NestedDependencyMissingResolveTest() { InvertContainer container = new InvertContainer(); container.Register <MockParentDependency>(); Assert.Throws <DependencyNotFoundException>(() => { container.Resolve <MockParentDependency>(); }); }
public void NestedDependencyResolveTest() { InvertContainer container = new InvertContainer(); container.Register <MockParentDependency>(); container.Register <MockChildDependency>(); Assert.NotNull(container.Resolve <MockParentDependency>()); }
static void Main(string[] args) { InvertContainer container = new InvertContainer(); container.Register <IFoo>().To <Foo>(); Console.WriteLine(container.Resolve <IFoo>()); Console.ReadKey(); }
public void DependencyMissingTest() { InvertContainer container = new InvertContainer(); Assert.Throws <DependencyNotFoundException>(() => { container.Resolve <MockDependency>(); }); }