You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.CommandLine is a package from MS for parsing command-line arguments. It fails to do this properly when asked to invoke a method on a mocked object.
where _builderService and _builderMock are both IBuilderService, but RunAsync only works when _builderService is a real BuilderService and not a mock.
When _builderService is a mock BuildForSingleTable is never called and InvokeAsync returns 1, indicating an error I presume, but when _builderService is a concrete BuilderService, InvokeAsync returns 0 and my method is called.
I thought I'd open an issue because here Moq is failing in what it's supposed to do: appear to a method as a normal object. I have also reported this on the System.CommandLine repo. I am using Moq
The text was updated successfully, but these errors were encountered:
It's a bit tedious having to piece together a repro from prose. Please post a minimal but complete code repro, otherwise there's nothing we can do to help.
I have since found out that using a stub with a string[] array passed as args has the same effect. I may have something wrong with my args setup so I will close this and wait and see before I open another one. Sorry about that.
System.CommandLine
is a package from MS for parsing command-line arguments. It fails to do this properly when asked to invoke a method on a mocked object.With the following code in
ApplicationService
:and this mocking code:
where
_builderService
and_builderMock
are bothIBuilderService
, butRunAsync
only works when_builderService
is a realBuilderService
and not a mock.When
_builderService
is a mockBuildForSingleTable
is never called andInvokeAsync
returns 1, indicating an error I presume, but when_builderService
is a concreteBuilderService
,InvokeAsync
returns 0 and my method is called.I thought I'd open an issue because here Moq is failing in what it's supposed to do: appear to a method as a normal object. I have also reported this on the
System.CommandLine
repo. I am using MoqThe text was updated successfully, but these errors were encountered: