private static void VerifyDefaultConstructor <T>(VariantEquatableCallback equatableCallback , VariantComparableCallback comparableCallback, Action <T> verify) { var instance = Variant.Create <T>(VariantConfigurationCollection.Create( VariantConfiguration.Configure <T>(equatableCallback, comparableCallback) ) ); Assert.NotNull(instance); verify(instance.Value); }
public void Ctor_Default_Value_Misconfigured_Config_Throws() => VerifyMisconfiguredVariant( x => new Variant <int>(x), default(int) , VariantConfigurationCollection.Create(VariantConfiguration.Configure <long>()) );
public void Create_Incompatible_Variant_Types_Instance_Throws() => VerifyInvalidVariantCombination < DerivedClass, BaseClass>((type, x, cfg) => (Variant <DerivedClass>)Variant.Create(type, x, cfg) , new BaseClass(), VariantConfigurationCollection.Create(VariantConfiguration.Configure <BaseClass>()) );
public void Ctor_Incompatible_Variant_Types_Null_Value_Config_Value_Throws() => VerifyInvalidVariantCombination < DerivedClass, BaseClass>((type, x, cfg) => new Variant <DerivedClass>(type, x, cfg) , null, VariantConfigurationCollection.Create(VariantConfiguration.Configure <BaseClass>()) );