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

Notification

Icon
Error

VS 2019 Enterprise 16.8 RTM - MS Fakes - Not Working
upper
#1 Posted : Sunday, November 15, 2020 2:50:03 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/21/2016(UTC)
Posts: 31
Location: Austria

Thanks: 8 times
Was thanked: 8 time(s) in 7 post(s)
We are using NCrunch 4.5.0.3

MS Fakes are no longer working with the latest VS 2019 Enterprise 16.8 RTM version, NCrunch shows the following error:

Test method YYY.Notifications.CommandHandler.Test.Messages.CommandValidatorBehaviour.Validate_Should_ThrowFaultException_When_ContextIsNull threw exception:
Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotSupportedException: YYY.Notifications.Contract.Commands.SendNotificationCommand
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InvokeEvent[T](T value, Action`1 eh)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.OnAttachedUnsupportedMethod(MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.CheckInstrumentation(MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InternalAttachDetour(Object optionalReceiver, MethodBase method, Delegate detourDelegate)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.AttachDetour(Object optionalReceiver, MethodBase method, Delegate detourDelegate)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShimMethod(Delegate optionalStub, Object optionalReceiver, MethodBase method)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShim(Delegate optionalStub, Type receiverType, Object optionalReceiver, String name, ShimBinding flags, Type returnType, Type[] parameterTypes)
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.SetShimPublicInstance(Delegate optionalStub, Type receiverType, Object optionalReceiver, String name, Type returnType, Type[] parameterTypes)
at YYY.Notifications.Contract.Commands.Fakes.ShimSendNotificationCommand.set_ContextGet(Func`1 value)
at YYY.Notifications.CommandHandler.Test.Messages.CommandValidatorBehaviour.Validate_Should_ThrowFaultException_When_ContextIsNull() in C:\Dev\Vie\Notification\Src\NS\v\1.39\YYY.Notifications.CommandHandler.Tests\Messages\CommandValidatorBehaviour.cs:line 73



We are using SDK-based project file with .NET 4.7.2 (everyhing was working fine with a previous version of VS 2019 Enterprise Edition.
We are using MsTestV2.

The Visual Studio Test Runner is working fine.

We use this nuget package from MS to use fakes (should also be working with .net core projects):
https://www.nuget.org/pa...akes/16.7.4-beta.20330.2
Remco
#2 Posted : Sunday, November 15, 2020 10:57:46 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)
Thanks for sharing this. Can you confirm whether you've tried regenerating the derived files used by Fakes to see if this solves the issue? Often a big platform release can put them out of sync, giving obscure errors.
UppSol
#3 Posted : Monday, November 16, 2020 12:21:17 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 3/21/2019(UTC)
Posts: 41
Location: Austria

Thanks: 30 times
Was thanked: 7 time(s) in 7 post(s)
Remco;15066 wrote:
Thanks for sharing this. Can you confirm whether you've tried regenerating the derived files used by Fakes to see if this solves the issue? Often a big platform release can put them out of sync, giving obscure errors.


If cleaned the bin + obj folder and rebuilded the project, so the fakes project(generated by VS/compiler) and the corresponding (generated) files have been rebuilded correctly.
Should this be enough or should I do something else as well?

Br
Remco
#4 Posted : Monday, November 16, 2020 12:25:15 AM(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)
UppSol;15067 wrote:

If cleaned the bin + obj folder and rebuilded the project, so the fakes project(generated by VS/compiler) and the corresponding (generated) files have been rebuilded correctly.
Should this be enough or should I do something else as well?


Fakes generates its own assemblies which are stored separately. You'll need to right-click the references in solution explorer and choose to (re)generate the fakes assemblies.
upper
#5 Posted : Monday, November 16, 2020 6:33:01 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/21/2016(UTC)
Posts: 31
Location: Austria

Thanks: 8 times
Was thanked: 8 time(s) in 7 post(s)
Remco;15068 wrote:
UppSol;15067 wrote:

If cleaned the bin + obj folder and rebuilded the project, so the fakes project(generated by VS/compiler) and the corresponding (generated) files have been rebuilded correctly.
Should this be enough or should I do something else as well?


Fakes generates its own assemblies which are stored separately. You'll need to right-click the references in solution explorer and choose to (re)generate the fakes assemblies.


OK, I just tried it right now and unfortunately it does not solve the problem.

Maybe that's the reason, found from a MS-How To: https://docs.microsoft.c...soft-fakes?view=vs-2019

(ResolveAssemblyReferences target) ->
warning MSB3245: Could not resolve this reference. Could not locate the assembly "AssemblyName.Fakes". Check to make sure the assembly exists on disk.
If this reference is required by your code, you may get compilation errors.

This warning is due to necessary changes made in Fakes generation can be ignored. It can be avoided by removing the assembly reference from the project file, because we now implicitly add them during the build.

^^ We removed the referenced fakes assembly to get rid of the warning!

I also tried to specify the Fakes folder (with the generated fake assemblies) as "Additional files to include"

Br
Remco
#6 Posted : Monday, November 16, 2020 8:24:59 AM(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)
Sorry just trying to confirm the status here ... Does the problem still exist after the adjustments you made?

If so, is it possible for you to reproduce it with a sample solution?
upper
#7 Posted : Monday, November 16, 2020 8:28:53 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/21/2016(UTC)
Posts: 31
Location: Austria

Thanks: 8 times
Was thanked: 8 time(s) in 7 post(s)
Remco;15070 wrote:
Sorry just trying to confirm the status here ... Does the problem still exist after the adjustments you made?

If so, is it possible for you to reproduce it with a sample solution?


Yeah the problem still exists, I will try to reproduce it with a small sample.

br
1 user thanked upper for this useful post.
Remco on 11/16/2020(UTC)
upper
#8 Posted : Monday, November 16, 2020 11:25:10 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/21/2016(UTC)
Posts: 31
Location: Austria

Thanks: 8 times
Was thanked: 8 time(s) in 7 post(s)
upper;15071 wrote:
Remco;15070 wrote:
Sorry just trying to confirm the status here ... Does the problem still exist after the adjustments you made?

If so, is it possible for you to reproduce it with a sample solution?


Yeah the problem still exists, I will try to reproduce it with a small sample.

br


Here is a very simple project (I tested it on 3 different computers) with NCrunch 4.6.0.1 and NCrunch 4.5.0.3 and it shows exactly the same error I posted above

https://drive.google.com...KlTdd-/view?usp=sharing

BR
Remco
#9 Posted : Monday, November 16, 2020 11:32:14 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)
Great, thanks! We'll take a look and will get back to you soon.
Remco
#10 Posted : Wednesday, November 18, 2020 12:20:27 AM(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)
An update on this one. We haven't been able to find an obvious cause for this problem. Since most of the operation of MSFakes is a black box to us, it'll probably take some time before we know what's going on. We'll update you when we have more information.
1 user thanked Remco for this useful post.
UppSol on 11/18/2020(UTC)
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.077 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download