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

Notification

Icon
Error

Getting Generics error on 3.18.0.2 that wasn't there in 3.17.x
GethinStevens
#1 Posted : Friday, August 17, 2018 3:21:10 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/17/2018(UTC)
Posts: 1
Location: United Kingdom

Visual Studio Version: VS2017
OS: W10
Test Framework: MSTest v2

I have the following test:

public abstract class UpdatableFieldTests<T> : GenericDealUpdatableFieldTests<T> where T : class, IUpdatableField
{
public static object[] InvalidDealTypes
{
get
{
var result=(from item in Enum.GetValues(typeof(DealType))
.OfType<DealType>()
where item != DealType.FixedFloat && item != DealType.FloatFloat
select new object[] { item }).ToArray();

return result;
}
}

[TestMethod]
[DynamicData(nameof(InvalidDealTypes))]
public void UserWithDealType_ForNonSwapDeals_ReturnsFalse(DealType dealType)
{
//Arrange
var field = GetTestInstance();
//Act
var result = field.UseWithDealType(dealType);
//Assert
Assert.IsFalse(result);
}
}

Other classes inherit from this base class and execute UserWithDealType_ForNonSwapDeals_ReturnsFalse. This worked fine for NCrunch 2.17 but is now breaking with:

System.InvalidOperationException: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
at System.Reflection.RuntimeMethodInfo.ThrowNoInvokeException()
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at nCrunch.Module.MSTest.Integration.MSTestDynamicDataSourceMethod.TryGetAllTestCaseParameters()
at nCrunch.Module.MSTest.Integration.MSTestTest.Run()

Remco
#2 Posted : Friday, August 17, 2018 11:46:56 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

Support for DynamicDataAttribute is newly introduced in NCrunch v3.17. The reason you haven't seen this fail on older versions of NCrunch is likely because the test wasn't being detected and reported. At the time NCrunch 2.17 was released, MSTest v2 didn't exist yet.

This problem appears to be related to the dynamic data method being declared on a generic class. NCrunch will require a code fix to handle such a scenario (I'm assuming MSTest is currently OK with it). We'll look into this to see if such a fix is possible in a future release.

For the time being, I recommend avoiding the use of DynamicData methods on classes that make use of generics.
Remco
#3 Posted : Sunday, August 26, 2018 11:13:32 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
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.034 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download