-
Notifications
You must be signed in to change notification settings - Fork 77
Conversation
It seems that's possible https://twitter.com/ptrelford/status/314784763015753728. I agree it's better and more flexibile with a mocking framework. |
The same error: Code let documentFactoryService =
Mock<ITextDocumentFactoryService>()
.SetupByName("TryGetTextDocument")
.Calls<ITextBuffer * byref<ITextDocument>>(fun (textBuffer, textDocument) ->
textBuffer.Properties.TryGetProperty(typeof<ITextDocument>, &textDocument))
.Create() /cc @ptrelford |
@ptrelford We are mocking C# classes; most of mocking calls from F# projects but there are some from a C# project. We have a problem with mocking C# calls with |
let classificationRegistry = | ||
Mock<IClassificationTypeRegistryService>() | ||
.Setup(fun x -> <@ x.GetClassificationType (any()) @>) | ||
.Calls<string>(fun t -> Mock<IClassificationType>.With(fun x -> <@ x.Classification --> t @>)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this -->
thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means that x.Classification will return t.
I'm merging this as an improvement. It would be great to fix the issue with |
replace some poor man mocks with Foq
I've implemented early support for byref args using Calls in Foq, see changeset: https://foq.codeplex.com/SourceControl/changeset/9606bc475eca In your example you should be able to specify:
Which should pass the ITextDocument byref argument by value to the specified function. You can check the functionality by building Foq from source or by copying the latest Foq.fs into your project: https://foq.codeplex.com/SourceControl/latest#Foq/Foq.fs It would be great to get your feedback on the implementation before I push out a new Nuget package. |
It doesn't work; test runners crash whenever I use You could reproduce this by uncommenting relevant sections and running |
@dungpa thanks, I'll take a look |
@ptrelford Hi Phil, is there any progress? |
No description provided.