public IMessage PublishMessage(IMessagePublishParameters parameter) { if (parameter == null) { throw new ArgumentNullException("Parameter cannot be null."); } var publishedMessageDTO = _messageQueryExecutor.PublishMessage(parameter); return _messageFactory.GenerateMessageFromMessageDTO(publishedMessageDTO); }
public IMessage PublishMessage(IMessagePublishParameters parameter) { if (parameter == null) { throw new ArgumentNullException("Parameter cannot be null."); } var publishedMessageDTO = _messageQueryExecutor.PublishMessage(parameter); return(_messageFactory.GenerateMessageFromMessageDTO(publishedMessageDTO)); }
// Publish Message public string GetPublishMessageQuery(IMessagePublishParameters parameters) { var messageText = parameters.Text; var recipient = parameters.Recipient; if (!_messageQueryValidator.IsMessageTextValid(messageText) || !_userQueryValidator.CanUserBeIdentified(recipient)) { return(null); } string identifierParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(recipient); return(GetPublishMessageFormattedQuery(messageText, identifierParameter)); }
private void ArrangeMessageDTORecipient( IMessagePublishParameters parameters, bool isRecipientValid, bool isRecipientIdValid, bool isRecipientScreenNameValid) { var recipient = A.Fake <IUserDTO>(); var recipientId = TestHelper.GenerateRandomLong(); var recipientScreenName = TestHelper.GenerateString(); parameters.CallsTo(x => x.Recipient).Returns(recipient); parameters.CallsTo(x => x.RecipientId).Returns(recipientId); parameters.CallsTo(x => x.RecipientScreenName).Returns(recipientScreenName); _fakeUserQueryValidator.CallsTo(x => x.CanUserBeIdentified(recipient)).Returns(isRecipientValid); _fakeUserQueryValidator.CallsTo(x => x.IsUserIdValid(recipientId)).Returns(isRecipientIdValid); _fakeUserQueryValidator.CallsTo(x => x.IsScreenNameValid(recipientScreenName)).Returns(isRecipientScreenNameValid); }
public bool CanMessageBePublished(IMessagePublishParameters parameters) { var message = parameters.Message; var text = parameters.Text; bool messageTextIsValid = IsMessageTextValid(text); bool isRecipientValid = _userQueryValidator.CanUserBeIdentified(parameters.Recipient) || _userQueryValidator.IsUserIdValid(parameters.RecipientId) || _userQueryValidator.IsScreenNameValid(parameters.RecipientScreenName); bool isMessageInValidState = message == null || (!message.IsMessagePublished && !message.IsMessageDestroyed); if (!isMessageInValidState) { return false; } return isRecipientValid && messageTextIsValid; }
public bool CanMessageBePublished(IMessagePublishParameters parameters) { var message = parameters.Message; var text = parameters.Text; bool messageTextIsValid = IsMessageTextValid(text); bool isRecipientValid = _userQueryValidator.CanUserBeIdentified(parameters.Recipient) || _userQueryValidator.IsUserIdValid(parameters.RecipientId) || _userQueryValidator.IsScreenNameValid(parameters.RecipientScreenName); bool isMessageInValidState = message == null || (!message.IsMessagePublished && !message.IsMessageDestroyed); if (!isMessageInValidState) { return(false); } return(isRecipientValid && messageTextIsValid); }
private void ArrangeQueryGeneratorPublishMessage(IMessagePublishParameters parameters, string query) { _fakeMessageQueryGenerator .CallsTo(x => x.GetPublishMessageQuery(parameters)) .Returns(query); }
public string PublishMessage(IMessagePublishParameters parameters) { string query = _messageQueryGenerator.GetPublishMessageQuery(parameters); return(_twitterAccessor.ExecuteJsonPOSTQuery(query)); }
/// <summary> /// Publish a message /// </summary> public static IMessage PublishMessage(IMessagePublishParameters parameters) { return MessageController.PublishMessage(parameters); }
private void ArrangeQueryGeneratorPublishMessage(IMessagePublishParameters parameters, string query) { _fakeMessageQueryGenerator .CallsTo(x => x.GetPublishMessageQuery(parameters)) .Returns(query); }
// Publish Message public IMessageDTO PublishMessage(IMessagePublishParameters parameters) { string query = _messageQueryGenerator.GetPublishMessageQuery(parameters); return _twitterAccessor.ExecutePOSTQuery<IMessageDTO>(query); }
private void ArrangeMessageDTORecipient( IMessagePublishParameters parameters, bool isRecipientValid, bool isRecipientIdValid, bool isRecipientScreenNameValid) { var recipient = A.Fake<IUserDTO>(); var recipientId = TestHelper.GenerateRandomLong(); var recipientScreenName = TestHelper.GenerateString(); parameters.CallsTo(x => x.Recipient).Returns(recipient); parameters.CallsTo(x => x.RecipientId).Returns(recipientId); parameters.CallsTo(x => x.RecipientScreenName).Returns(recipientScreenName); _fakeUserQueryValidator.CallsTo(x => x.CanUserBeIdentified(recipient)).Returns(isRecipientValid); _fakeUserQueryValidator.CallsTo(x => x.IsUserIdValid(recipientId)).Returns(isRecipientIdValid); _fakeUserQueryValidator.CallsTo(x => x.IsScreenNameValid(recipientScreenName)).Returns(isRecipientScreenNameValid); }
private void ArrangeMessagePublishParameterText(IMessagePublishParameters parameters, bool doesTextExists, bool textContainsChars) { string text = doesTextExists ? textContainsChars ? TestHelper.GenerateString() : string.Empty : null; parameters.CallsTo(x => x.Text).Returns(text); }
private void ArrangeMessagePublishParameterText(IMessagePublishParameters parameters, bool doesTextExists, bool textContainsChars) { string text = doesTextExists ? textContainsChars ? TestHelper.GenerateString() : string.Empty : null; parameters.CallsTo(x => x.Text).Returns(text); }
// Publish Message public static async Task<IMessage> PublishMessage(IMessagePublishParameters parameters) { return await Sync.ExecuteTaskAsync(() => Message.PublishMessage(parameters)); }
// Publish Message public string GetPublishMessageQuery(IMessagePublishParameters parameters) { var messageText = parameters.Text; var recipient = parameters.Recipient; if (!_messageQueryValidator.IsMessageTextValid(messageText) || !_userQueryValidator.CanUserBeIdentified(recipient)) { return null; } string identifierParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(recipient); return GetPublishMessageFormattedQuery(messageText, identifierParameter); }
// Publish Message public static async Task <IMessage> PublishMessage(IMessagePublishParameters parameters) { return(await Sync.ExecuteTaskAsync(() => Message.PublishMessage(parameters))); }