Are there too many asserts in this unit test? -


are there many asserts in 1 unit test?

[fact] public void send_sends_an_email_message() {     using (var server = new mocksmtpserver()) {         server.start();         using (var client = new emailclient("localhost")) {             string = "john.doe@example.com";             ienumerable<string> = new[] { "jane.doe@example.com" };             string subject = "test";             string body = "test.";             client.send(from, to, subject, body);             var session = server.sessions.firstordefault();             assert.notnull(session);             var message = session.messages.firstordefault();             assert.notnull(message);             assert.notnull(message.from);             assert.equal(message.from.address, "john.doe@example.com");             assert.notnull(message.to);             var recipient = message.to.firstordefault();             assert.notnull(recipient);             assert.equal(recipient.address, "jane.doe@example.com");             assert.equal(message.subject, "test");             assert.equal(message.body, "test.");         }     } } 

i don't think code requires explanation, if please let me know.

i try keep unittests small , test 1 thing @ time. i'd make testing distinct parts separate tests, e.g.

  • sendwillsendanemail,
  • fromcontainssenderaddress,
  • tocontainsrecipientaddress,
  • mailbodycontainsmailmessage,
  • mailcontainssubject

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -