Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After upgrading to 2.2.3 to 2.2.4 getting a argument exception on datarow unit test #839

Closed
davesmits opened this issue May 26, 2021 · 5 comments
Assignees

Comments

@davesmits
Copy link

davesmits commented May 26, 2021

Steps to reproduce

Create this unit test

[TestClass]
    public class Test
    {
        [DataTestMethod]
        [DataRow(52.131d)]
        public void Doubles(double value)
        {
        }
    }

results in :
Test method Pandora.Reasoning.Rules.Tests.Extensions.Test.Doubles threw exception:
System.ArgumentException: Object of type 'System.Decimal' cannot be converted to type 'System.Double'.

Expected behavior

Unit test completes successfully

Actual behavior

unit test fails in Test method Pandora.Reasoning.Rules.Tests.Extensions.Test.Doubles threw exception:
System.ArgumentException: Object of type 'System.Decimal' cannot be converted to type 'System.Double'.

@Akinzekeel
Copy link

I am also encountering this problem. I also have problems with tests that use a Type or a char in the DataRow attribute (char cannot be converted to string, System.Type cannot be serialized)

@Sanan07
Copy link
Contributor

Sanan07 commented May 26, 2021

Did you also update Microsoft.NET.Test.Sdk in project? I do not see any changes related to DataRow logic in 2.2.4.
@Haplois can you please look at these issues after upgrading to 2.2.4?

@davesmits
Copy link
Author

davesmits commented May 26, 2021

Just created a new project; updated the nuget packages
now using

 <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.4" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.4" />
    <PackageReference Include="coverlet.collector" Version="3.0.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

this is this unit test:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {

        [DataTestMethod]
        [DataRow(52.131d)]
        public void Doubles(double value)
        {
        }

    }
}

same output

here is the project I used: TestProject1.zip

visual studio version info:
Microsoft Visual Studio Enterprise 2019
Version 16.10.0
VisualStudio.16.Release/16.10.0+31321.278
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools 00435-60000-00000-AA497
Microsoft Architecture Diagrams and Analysis Tools

Visual C++ 2019 00435-60000-00000-AA497
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019 16.10.525.31942
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.10.525.31942
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.10.525.31942
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.10.525.31942
Azure Functions and Web Jobs Tools

C# Tools 3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio 2.11.106.19330
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.40423.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.2
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

NuGet Package Manager 5.10.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Razor (ASP.NET Core) 16.1.0.2122504+13c05c96ea6bdbe550bd88b0bf6cdddf8cde1725
Provides languages services for ASP.NET Core Razor.

Snapshot Debugging Extension 1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.62105.04180
Microsoft SQL Server Data Tools

TypeScript Tools 16.0.30429.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 16.10.0-beta.21262.7+1b23bbeda88ea3cb9be9af777f4c99fa8663df81
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions 1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

Visual Studio Tools for Kubernetes 1.0
Visual Studio Tools for Kubernetes

@chriswelles
Copy link

Something has clearly broken with how DataRow's are serialized. With the update to 2.2.4 (from 2.2.3), I get the error:

An exception occurred while invoking executor 'executor://mstestadapter/v2': Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

The test that breaks things has DataRow's that look like:

[DataRow(DeviceState.Offline, Severity.Offline, new string[] { "1" }, Severity.Critical, new string[] { }, Severity.Warning, new string[] { }, Severity.Informational, new string[] { }, Status.Offline)]

It can't handle String arrays (along with all sorts of other things it seems).

@Haplois Haplois self-assigned this May 27, 2021
@Haplois
Copy link
Contributor

Haplois commented May 27, 2021

Thank you for reporting this, it's a known issue - we're working on it. It's tracked here.

@Haplois Haplois closed this as completed May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants