Cabster.Test/TestExtensions.cs
/// <summary>
///     Descartar controles com 100% de teste de cobertura.
/// </summary>
/// <param name="control">Controle</param>
Descartar controles com 100% de teste de cobertura.
Descartar controles com 100% de teste de cobertura .
public static T Descartar<T>(this T control) where T : Control
        {
            control
                .GetType()
                .GetField("components", BindingFlags.Instance | BindingFlags.NonPublic)
                ?.SetValue(control, Substitute.For<IContainer>());
            ((IDisposable) control).Dispose();
            return control;
        }
public static T Descartar < T > ( this T control ) where T : Control { control . GetType ( ) . GetField ( " " , BindingFlags . Instance | BindingFlags . NonPublic ) ? . SetValue ( control , Substitute . For < IContainer > ( ) ) ; ( ( IDisposable ) control ) . Dispose ( ) ; return control ; }
Descartar controles com 100% de teste de cobertura.
Descartar controles com 100% de teste de cobertura .
// Necessário para teste de cobertura atingir 100%. // components é um atributo criado pelo Visual Studio e usado pelo modo Design. // https://stackoverflow.com/questions/5069391/whats-the-purpose-of-the-components-icontainer-generated-by-the-winforms-design
T
this
control
None