Note that there are some explanatory texts on larger screens.

plurals
  1. POvariable casting error in c#
    primarykey
    data
    text
    <pre><code>public CommandModule(ICommandFetcher fetcher,ICommandBus commandBus) { Post["/"] = parameters =&gt; { var commandRequest = this.Bind&lt;MessageEnvelope&gt;(); var command = fetcher.FetchFrom(commandRequest); commandBus.Send((ICommand)command, commandRequest.MetaData); return HttpStatusCode.OK; }; } </code></pre> <p>error-->Unable to cast object of type 'Castle.Proxies.ObjectProxy_2' to type 'Vetserve.Messages.Shared.ICommand'.</p> <p>in commandBus.Send((ICommand)command, commandRequest.MetaData); line </p> <p>Hi when i try to test using nunit test this method has previous error how can i fix it </p> <p>this is my test class</p> <pre><code> [Test] public void whern_reseiving_command_it_sent_to_the_command_bus() { var rCommand = new DummyCommand() {SomeProp = 2}; var serializedCommand = JsonConvert.SerializeObject(rCommand); var envelope = new MessageEnvelope() { MetaData = new MetaData() {MessageType = "DummyCommand", MessageTypeVersion = 1}, MessageData = serializedCommand }; var fakeCommand = A.Fake&lt;ICommandBus&gt;(); var fakeCxxommand = A.Fake&lt;ICommandFetcher&gt;(); var browser = new Browser(with =&gt; { with.Module&lt;CommandModule&gt;(); with.Dependency&lt;ICommandBus&gt;(fakeCommand); with.Dependency&lt;ICommandFetcher&gt;(fakeCxxommand); }); var result = browser.Post("/", with =&gt; { with.HttpRequest(); with.JsonBody(envelope); }); A.CallTo(() =&gt; fakeCommand.Send(A&lt;ICommand&gt;.Ignored , envelope.MetaData)).MustHaveHappened(); // A.CallTo(() =&gt; fakeCommand.Send(A&lt;ICommand&gt;.Ignored, A&lt;MetaData&gt;._)).MustHaveHappened(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload