public void Instanciate_NotInterface_ThrowArgumentException() { var registry = new DependancyRegistry(); void testAction() => registry.Instantiate <TestedInheritingClass>(); Assert.ThrowsException <ArgumentException>(testAction); }
public void Instanciate_InterfaceIsNotRegistered_ThrowArgumentException() { var registry = new DependancyRegistry(); void testAction() => registry.Instantiate <ITestedInterface>(); Assert.ThrowsException <ArgumentException>(testAction); }
public void Instanciate_InterfaceIsRegistered_ReturnsNewImplementation() { var registry = new DependancyRegistry(); registry.Register(typeof(ITestedInterface), typeof(TestedInheritingClass)); var instance = registry.Instantiate <ITestedInterface>(); Assert.IsTrue(instance is TestedInheritingClass); }
public void Register_InterfaceWithNonInheritingClass_ThrowArgumentException() { var interfaceType = typeof(ITestedInterface); var nonInheritingType = typeof(TestedNonInheritingClass); var registry = new DependancyRegistry(); void testAction() => registry.Register(interfaceType, nonInheritingType); Assert.ThrowsException <ArgumentException>(testAction); }
public void Register_InterfaceWithInheritingClass_AddsToRegistry() { var interfaceType = typeof(ITestedInterface); var inheritingType = typeof(TestedInheritingClass); var registry = new DependancyRegistry(); registry.Register(interfaceType, inheritingType); Assert.IsTrue(registry.Clone().ContainsKey(interfaceType)); }
public void Register_InterfaceRegisteredToDifferentType_ThrowArgumentException() { var interfaceType = typeof(ITestedInterface); var firstInheritingType = typeof(TestedInheritingClass); var secondInheritingType = typeof(TestedOtherInheritingClass); var registry = new DependancyRegistry(); registry.Register(interfaceType, firstInheritingType); void testAction() => registry.Register(interfaceType, secondInheritingType); Assert.ThrowsException <ArgumentException>(testAction); }