Open davidgruar opened 5 years ago
Have just hit this when trying to use Foq to mock the Microsoft.Azure.WebjobsDurableOrchestrationContextBase
type - I was attempting port the sample here https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-unit-testing#unit-testing-orchestrator-functions to use Foq
It should be noted that I can use Moq in f# to re-create that sample and mock the type without issue but I really like the use of quotations in Foq!
Any progress on this issue? I just ran into it after upgrading to latest Azure.Storage.Blobs library (12.11.0). The Azure.Response
type can no longer be mocked:
let resp = Foq.Mock<Azure.Response>().Create()
Fails at runtime with System.TypeLoadException : Method 'set_IsError' on type 'Mock.Responseda15e24f-4b36-4ebb-a375-a1c2b3ef1ec8' from assembly 'Foq.Dynamic, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a method that is not visible from that assembly.
Edit: I just noticed that the IsError
property is not even virtual. Now I'm really confused.
Description
Foq throws an exception if you try to mock a C# abstract class containing a virtual property with an internal setter.
Repro steps
Create the following class in a C# project:
Create this test in an F# test project:
Expected behavior
Test should pass.
Actual behavior
Fails with this error:
Stack Trace:
If you remove the
VirtualInternalSet
property, the test passes.Related information