Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

BUG: DynamicData does not work properly for Interfaces
TKrueger
#1 Posted : Monday, February 4, 2019 11:52:32 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/4/2019(UTC)
Posts: 4
Location: Germany

Thanks: 1 times
Code:

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();
	}
}
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.032 seconds.