public void ShouldSendContactUsMessageToHelpDeskEmailAddress() { // Arrange. var contactMessage = new ContactMessage { Type = ContactMessageTypes.ContactUs }; // Act. _strategy.SubmitMessage(contactMessage); // Assert. _communicationService.Verify(cs => cs.SendContactMessage( It.IsAny <Guid?>(), MessageTypes.CandidateContactUsMessage, It.Is <IEnumerable <CommunicationToken> >(communicationTokens => communicationTokens.First( each => each.Key == CommunicationTokens.RecipientEmailAddress).Value == ValidHelpdeskEmailAddress))); }
public void ShouldNotSendInvalidContactMessage() { // Arrange. var contactMessage = new ContactMessage { Type = ContactMessageTypes.Unknown }; // Act. _strategy.SubmitMessage(contactMessage); // Assert. _logService.Verify(mock => mock.Error(It.IsAny <string>(), It.IsAny <object[]>()), Times.Once); _communicationService.Verify(mock => mock.SendContactMessage( It.IsAny <Guid?>(), MessageTypes.CandidateContactUsMessage, It.IsAny <IEnumerable <CommunicationToken> >()), Times.Never); }
public void SubmitContactMessageTest() { //Arrange ProviderContactMessage providerContactMessage = new ProviderContactMessage { Email = "*****@*****.**", Details = "Message Details", Name = ValidUsername, Type = ContactMessageTypes.ContactUs, Enquiry = "Message Enquiry" }; var communicationTokens = default(IEnumerable <CommunicationToken>); _communicationService.Setup(mock => mock.SendMessageToProviderUser( It.IsAny <string>(), It.IsAny <MessageTypes>(), It.IsAny <IEnumerable <CommunicationToken> >())) .Callback <string, MessageTypes, IEnumerable <CommunicationToken> >( (u, m, t) => communicationTokens = t); //Act _submitContactMessageStrategy.SubmitMessage(providerContactMessage); _communicationService.Verify(mock => mock.SendMessageToProviderUser( "john", MessageTypes.ProviderContactUsMessage, It.IsAny <IEnumerable <CommunicationToken> >()), Times.Once); communicationTokens.ShouldAllBeEquivalentTo(new[] { new CommunicationToken(CommunicationTokens.UserFullName, providerContactMessage.Name), new CommunicationToken(CommunicationTokens.UserEnquiryDetails, providerContactMessage.Details), new CommunicationToken(CommunicationTokens.RecipientEmailAddress, ValidHelpdeskEmailAddress), new CommunicationToken(CommunicationTokens.UserEmailAddress, providerContactMessage.Email), new CommunicationToken(CommunicationTokens.UserEnquiry, providerContactMessage.Enquiry) }); }