Build/Test Issues

BUG: DynamicData does not work properly for Interfaces

Started by TKrueger on 2,754 views


public interface ISomeImplementation
{
	bool DoSomething();
}

public class SomeImplementation : ISomeImplementation
{
	public bool DoSomething()
	{
		return true;
	}
}

[TestClass, TestCategory("NCrunch.DynamicData")]
public class ImplementationVsInterfaceDynamicDataTest
{
	/*
	 * This test failed no matter which analyser setting I set for MSTest. But with different error messages:
	 * 
	 * StaticAnalysis: Type mismatch on test parameter 1 (NCrunchTest.ISomeImplementation != NCrunchTest.SomeImplementation)
	 * DynamicAnalysis: System.Exception: Type 'NCrunchTest.SomeImplementation' is not marked as serializable.  Resolution path = NCrunchTest.SomeImplementation
	 *
	 */

	public static IEnumerable<object[]> DoSomethingTestData
	{
		get
		{
			yield return new object[] { new SomeImplementation(), true, "Doubled input" };
		}
	}

	[DataTestMethod]
	[DynamicData(nameof(DoSomethingTestData), DynamicDataSourceType.Property)]
	public void DoSomethingTest(ISomeImplementation implementation, bool expected, string description)
	{
		implementation.DoSomething().Should().BeTrue();
	}
}
My apologies for the time it's taken to get back to you on this issue. The initial report slipped our net. The build below contains a targeted fix. Would you be interested in giving it a try?

NCrunch_Console_3.24.0.3.msi
NCrunch_Console_3.24.0.3.zip
NCrunch_GridNodeServer_3.24.0.3.msi
NCrunch_GridNodeServer_3.24.0.3.zip
NCrunch_LicenseServer_3.24.0.3.zip
NCrunch_VS2008_3.24.0.3.msi
NCrunch_VS2010_3.24.0.3.msi
NCrunch_VS2010_3.24.0.3.zip
NCrunch_VS2012_3.24.0.3.msi
NCrunch_VS2012_3.24.0.3.zip
NCrunch_VS2013_3.24.0.3.msi
NCrunch_VS2013_3.24.0.3.zip
NCrunch_VS2015_3.24.0.3.msi
NCrunch_VS2015_3.24.0.3.msi.7z
NCrunch_VS2015_3.24.0.3.zip
NCrunch_VS2017_3.24.0.3.msi
NCrunch_VS2017_3.24.0.3.msi.7z
NCrunch_VS2017_3.24.0.3.zip

Edited

Hello,

I tried the new version in my test project and main application. There the test has now been successfully completed.

Thanks
Hi,

I have tried to resolve my left issues in my main application and could not fix the following scenario as extension of the reported issue:


public static IEnumerable<object[]> DoSomethingTestData
{
	get
	{
		yield return new object[] { null, true, "Doubled input" };
	}
}

[DataTestMethod]
[DynamicData(nameof(DoSomethingTestData), DynamicDataSourceType.Property)]
public void DoSomethingTest(ISomeImplementation implementation, bool expected, string description)
{
	// No action required
}


Now I get the following result:

--------- DoSomethingTest ((null), True, Doubled input)
Type mismatch on test parameter 1 (parameter should not be null)


It seems to happen if null should be passed to an interface method parameter.

Thanks for your support.
You have a talent for finding these compatibility holes :) Sorry for the trouble here.

I've prepared another build with a fix for this issue:

NCrunch_Console_3.24.0.4.msi
NCrunch_Console_3.24.0.4.zip
NCrunch_GridNodeServer_3.24.0.4.msi
NCrunch_GridNodeServer_3.24.0.4.zip
NCrunch_LicenseServer_3.24.0.4.zip
NCrunch_VS2008_3.24.0.4.msi
NCrunch_VS2010_3.24.0.4.msi
NCrunch_VS2010_3.24.0.4.zip
NCrunch_VS2012_3.24.0.4.msi
NCrunch_VS2012_3.24.0.4.zip
NCrunch_VS2013_3.24.0.4.msi
NCrunch_VS2013_3.24.0.4.zip
NCrunch_VS2015_3.24.0.4.msi
NCrunch_VS2015_3.24.0.4.msi.7z
NCrunch_VS2015_3.24.0.4.zip
NCrunch_VS2017_3.24.0.4.msi
NCrunch_VS2017_3.24.0.4.msi.7z
NCrunch_VS2017_3.24.0.4.zip
Good morning,

I tried the new version in my test project and main application. The tests there have now been successfully completed.

Thank you for your fast support.
Great to hear! Thanks for confirming.

Post a reply

Log in to reply.