Tortuga-TestMonkey icon indicating copy to clipboard operation
Tortuga-TestMonkey copied to clipboard

IDisposable Tests

Open Grauenwolf opened this issue 3 years ago • 0 comments

foreach (var constructor in Class.Constructors.Where(c => c.IsCreatable)) 
{ 
	<text>
	
    @Tag("IDisposable")
	@TestAttribute
	public void @(Test.ClassName + "_DisposeTwice_" + constructor.SafeName)()
    {
		IDisposable objectUnderTest = @constructor.GetConstructorCode();

		try
		{
			objectUnderTest = @constructor.GetConstructorCode();
		}
		catch (ArgumentException)
		{
            return; //cannot continue test
		}

        objectUnderTest.Dispose();
        objectUnderTest.Dispose(); //second call should be a no-op 
	}
			
	</text>	
}

Grauenwolf avatar Jun 02 '21 01:06 Grauenwolf