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);
}
}
|