title: Writing NUnit Test Cases for method
body: <p>i am new for Nunit.please help for write a test case.
  this is my class</p>
  
  <pre><code>    public CommandModule(ICommandFetcher fetcher,ICommandBus commandBus)
      {
  
          //Get["/"] = p =&gt;
          //{z
          //    return Response.AsText((string)Request.Form.Username);
          //};
  
          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>and i want to test for check this method</p>
  
  <pre><code>  commandBus.Send((ICommand)command, commandRequest.MetaData);
  </code></pre>
  
  <p>thank you!</p>
  
  <p>i try it following way </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 browser = new Browser(with =&gt;
          {
              with.Module&lt;CommandModule&gt;();
              with.Dependency&lt;ICommandBus&gt;(fakeCommand);
  
          });
  
          var result = browser.Post("/", with =&gt;
          {
              with.HttpRequest();
              with.JsonBody(envelope);
          });
  
          A.CallTo(() =&gt; fakeCommand.Send(rCommand,envelope.MetaData)).MustHaveHappened();
  </code></pre>
  
  <p>but <code>A.CallTo(() =&gt; fakeCommand.Send(rCommand,envelope.MetaData)).MustHaveHappened();</code>
  it has some kind of error in rcommand value </p>