public void CanSetExplicitConstruction() { Assert.That(TypeConstruction.CanBeConstructed <ParameterConstructorType>(), Is.False); TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction); Assert.That(TypeConstruction.CanBeConstructed <ParameterConstructorType>(), Is.True); { var instance = TypeConstruction.Construct <ParameterConstructorType>(); Assert.That(instance, Is.Not.Null); Assert.That(instance.Value, Is.EqualTo(10.0f)); } TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction); Assert.That(TypeConstruction.CanBeConstructed <ParameterConstructorType>(), Is.False); }
public void SettingAndUnSettingAnExplicitConstructionMethod_ToCreateAnInstance_BehavesProperly() { Assert.That(TypeConstruction.CanBeConstructed <ParameterConstructorType>(), Is.False); Assert.That(TypeConstruction.CanBeConstructed(typeof(ParameterConstructorType)), Is.False); TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction); Assert.That(TypeConstruction.CanBeConstructed <ParameterConstructorType>(), Is.True); Assert.That(TypeConstruction.CanBeConstructed(typeof(ParameterConstructorType)), Is.True); { var instance = TypeConstruction.Construct <ParameterConstructorType>(); Assert.That(instance, Is.Not.Null); Assert.That(instance.Value, Is.EqualTo(10.0f)); } TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction); Assert.That(TypeConstruction.CanBeConstructed <ParameterConstructorType>(), Is.False); Assert.That(TypeConstruction.CanBeConstructed(typeof(ParameterConstructorType)), Is.False); }
public void SettingAndUnSettingAnExplicitConstructionMethod_WhenNoneAlreadySet_DoesNotThrow() { Assert.DoesNotThrow(() => TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction)); Assert.DoesNotThrow(() => TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction)); }
public void TryingToUnsetAnExplicitConstructionMethod_WithAnotherExplicitConstructionMethodSet_ReturnsFalse() { TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction); Assert.That(TypeConstruction.TryUnsetExplicitConstructionMethod(OtherExplicitConstruction), Is.False); TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction); }
public void TryingToSetAnExplicitConstructionMethod_WhenAlreadySet_ReturnsFalse() { TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction); Assert.That(TypeConstruction.TrySetExplicitConstructionMethod(ExplicitConstruction), Is.False); TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction); }
public void UnSettingAnExplicitConstructionMethod_WithAnotherExplicitConstructionMethodSet_Throws() { TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction); Assert.Throws <InvalidOperationException>(() => TypeConstruction.UnsetExplicitConstructionMethod(OtherExplicitConstruction)); TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction); }
public void UnSettingAnExplicitConstructionMethod_WhenNoExplicitConstructionMethodIsRegistered_Throws() { Assert.Throws <InvalidOperationException>(() => TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction)); }
public void SettingAnExplicitConstructionMethod_WhenAlreadySet_Throws() { TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction); Assert.Throws <InvalidOperationException>(() => TypeConstruction.SetExplicitConstructionMethod(ExplicitConstruction)); TypeConstruction.UnsetExplicitConstructionMethod(ExplicitConstruction); }