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

Notification

Icon
Error

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

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

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Code:

public static class StringExtensions
{
	/// <summary>
	/// Strips HTML tags from value
	/// </summary>
	/// <param name="value">The value</param>
	/// <returns>Doubled value</returns>
	public static string DoSomething(this string value)
	{
		if (value == null)
		{
			return null;
		}

		return value + value;
	}
}


[TestClass, TestCategory("NCrunch.DynamicData")]
public class StringExtensionDynamicDataTest
{
	/* 
	 * NCrunch analyse process dies at test with extensions with null input:
	 * 
	 * An error occurred while analysing this project after it was built: System.NullReferenceException: Object reference not set to an instance of an object.
	 * at System.Object.GetType()
	 * at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.<createDynamicDataSourceTests>b__7_0(Object p)
	 * at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
	 * at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.createDynamicDataSourceTests(List`1 frameworkTests, IMSTestParameterSupplier parameterSupplier, ReflectedMethod method, ReflectedType fixture, Factory testNameFactory)
	 * at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.<>c__DisplayClass5_0.<FindFrameworkTestsInAssembly>b__1()
	 * at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
	 * at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
	 * at nCrunch.TestExecution.TestFinder.<>c__DisplayClass2_2.<FindTestsForFrameworks>b__2()
	 * at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
	 * at nCrunch.TestExecution.TestFinder.<>c__DisplayClass2_0.<FindTestsForFrameworks>b__0()
	 * at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
	 * at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
	 * at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)
	 * 
	 */

	public static IEnumerable<object[]> DoSomethingTestData
	{
		get
		{
			yield return new object[] { "Test", "TestTest", "Doubled input" };
			yield return new object[] { "", "", "Empty string" };
			yield return new object[] { null, null, "Null string" };
		}
	}

	[DataTestMethod]
	[DynamicData(nameof(DoSomethingTestData), DynamicDataSourceType.Property)]
	public void DoSomethingTest(string input, string expected, string description)
	{
		input.DoSomething().Should().Be(expected, description);
	}
}
Remco
#2 Posted : Monday, February 4, 2019 7:59:09 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,722

Thanks: 744 times
Was thanked: 950 time(s) in 905 post(s)
Hi,

Thanks for sharing this issue. I've reproduced it exactly as you've described.

The problem is related to the nulls inside the object array, but you probably figured this out already :)

I'll see about arranging a fix.
michaelkroes
#3 Posted : Saturday, February 16, 2019 5:47:00 AM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 139
Location: Netherlands

Thanks: 64 times
Was thanked: 28 time(s) in 26 post(s)
1 user thanked michaelkroes for this useful post.
TKrueger on 2/22/2019(UTC)
TKrueger
#4 Posted : Friday, February 22, 2019 7:40:27 AM(UTC)
Rank: Newbie

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

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Hello,

I tried the new version in my test project. There the test has now been successfully completed.
Unfortunately this doesn't help me in my main application because of the two other issues I reported.


  1. DynamicData does not work properly for interfaces
  2. DynamicData does not work properly for class with null test


Please also check these points.
michaelkroes
#5 Posted : Friday, February 22, 2019 2:47:24 PM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 139
Location: Netherlands

Thanks: 64 times
Was thanked: 28 time(s) in 26 post(s)
Hi,

I'm sorry these posts have slipped my attention. I will have a look at them.

I'm glad that at least this is fixed. :)

Michael
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.036 seconds.