Validating NServiceBus Event Properties (Using Interfaces) -


i not able validate event published using nservicebus.testing ( nservicebus, v6 beta)

in api controller publish event

await _messagesession.publish<istrategycreated>(stgy => {      stgy.strategyid = strategytoadd.id;      stgy.investmentobjective = strategytoadd.investmentobjective;      stgy.principalinvestmentstrategy = strategytoadd.principalinvestmentstrategy;      stgy.portfolioconsultant = strategytoadd.portfolioconsultant;      stgy.strategyname = strategytoadd.name;      stgy.strategycode = strategytoadd.code; }); 

in test have:

assert.that(messagesession.publishedmessages.length, is.equalto(1), "messages published"); assert.isinstanceof<istrategycreated>(messagesession.publishedmessages[0],"message published of type istrategycreated"); 

the second line fails, because message type istrategycreated_impl error:

  message published of type istrategycreated   expected: instance of <strategy.contracts.events.istrategycreated>   was:  <nservicebus.testing.publishedmessage`1[system.object]> 

full test method:

    public async task testcreatestrategy ()     {          var messagesession = new testablemessagesession();         var dbcontent = _container.resolve<istrategydbcontext>();         var apicontext = new strategycontroller(messagesession, dbcontent);         var result =             await apicontext.create(new strategymodel {code = "new"})                 oknegotiatedcontentresult<strategymodel>;          assert.that(messagesession.publishedmessages.length, is.equalto(1), "messages published");         assert.isinstanceof<istrategycreated>(messagesession.publishedmessages[0],"message published of type istrategycreated");         var stgycreated =(istrategycreated) messagesession.publishedmessages[0];          assert.that(result, is.not.null, "result null");         assert.that(stgycreated.strategycode, is.equalto("new"));         assert.that(result?.content.code, is.equalto("new"), "returning strategy");         assert.that(dbcontent.strategies.count(), is.equalto(1), "exactly 1 item added strategy list");       } 

instead of messagesession.publishedmessages[0] use messagesession.publishedmessages[0].message, should work then.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -