简体   繁体   中英

NSubstitute -3.x 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard,

I am struggling to find a reason behind this error in my code:

ApplicationServiceTests\\Test.cs(29, 13): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

The code line is:

        repo.GetCoveredCards(Arg.Is(cifCode)).Returns(Task.FromResult(new GetCustomerCCPlusResponse()
        {
            CreditCardPlus = new[] { card1, card2 }
        }));

Tools, framework and Package

.net framework 4.6.1 Visual Studio 2015 using MSBuild 14. NSubstitute 3.1.0

It seems like when I use NSubstitute version 1.10.0 and it has worked really well.

Now the question is why am I getting this error with the latest version of NSubstitute?

I had the same issue after updating Visual studio. Delete the bin and obj folders from the UT project folder and rebuild the project. That fixed it for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM