public void AddContactAsync_should_send_ContactAdded_message_with_parsed_contact() { object lastMessage = null; var json = this.dto_1.SerializeToJson(); this.mockRestApi.Setup(x => x.ExecuteAsyncPostWithJson(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(json); this.mockMessanger.Setup(x => x.Send(It.IsAny <object>())) .Callback((object m) => lastMessage = m); contacts.AddContactAsync(new ContactViewModel(this.mockContacts.Object)); Assert.IsInstanceOf <ContactAdded>(lastMessage); var vm = ((ContactAdded)lastMessage).Contact; Assert.AreEqual(this.dto_1.Id, vm.Id); Assert.AreEqual(this.dto_1.FirstName, vm.FirstName); Assert.AreEqual(this.dto_1.LastName, vm.LastName); Assert.AreEqual(this.dto_1.BirthDate, vm.BirthDate); Assert.AreEqual(this.dto_1.Emails.Length, vm.Emails.Count); Assert.AreEqual(this.dto_1.PhoneNumbers.Length, vm.PhoneNumbers.Count); }