You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the dynamic data source method as in the code below in the 'Additional context' area fails with the message in the comment.
If the line fooValues = new SortedSet<int>(); is commented out it starts to work.
Happened to me with version 2.2.10.
Additional context
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Testing
{
[TestClass]
public class Test
{
// This test fails with the following.
//
//Message:
//Collection interface type 'System.Collections.Generic.IEnumerable`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' is being used as a get-only property and does not have an Add method.Consider adding a setter to the property or using a collection data contract that does have an Add method - for example IList or ICollection<T>.
//
//Stack Trace:
//JsonCollectionDataContract.get_JsonFormatGetOnlyReaderDelegate()
//JsonCollectionDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
//JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
//XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
//XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
//ReadTest_FooFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
//JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
//JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
//XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
//XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
//XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
//DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
//XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
//XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
//DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader)
//DataContractJsonSerializer.ReadObject(Stream stream)
[TestMethod]
[DynamicData(nameof(GetTestData), DynamicDataSourceType.Method)]
public void TestMethod(string someString, Foo foo)
{
}
private static IEnumerable<object[]> GetTestData()
{
yield return new object[]
{
"", new Foo()
};
}
public class Foo
{
private readonly SortedSet<int> fooValues;
public IEnumerable<int> FooValues => fooValues;
public Foo()
{
// Make the test work by commenting out following line.
fooValues = new SortedSet<int>();
}
}
}
}
The text was updated successfully, but these errors were encountered:
This is yet another example of #1462. We are reviewing the options we can put in place to overcome these serialization/deserialization issues with parameterized tests.
Describe the bug
Using the dynamic data source method as in the code below in the 'Additional context' area fails with the message in the comment.
If the line
fooValues = new SortedSet<int>();
is commented out it starts to work.Happened to me with version 2.2.10.
Additional context
The text was updated successfully, but these errors were encountered: