public ActionResult <AddMessageStatusOutDto> Text([FromBody][Required] TextMessageDto message) { if (!ModelState.IsValid) { _logger.LogWarning("This model is invalid.", ModelState); return(BadRequest(ModelState)); } var messageEvent = new Message { MessageId = Guid.NewGuid().GetHashCode(), Text = message.Text, Chat = new Chat { Id = message.ChatId }, Date = DateTime.Now }; var result = _bot.MessageHandler(messageEvent); return(result ? Ok(new AddMessageStatusOutDto { Status = "successfully", MessageId = messageEvent.MessageId }) : StatusCode(500, new AddMessageStatusOutDto { Status = "failed", MessageId = messageEvent.MessageId })); }
public void MessageHandler_ChaId0_Return_False() { var message = _messageFake.RuleFor(m => m.Chat, f => new Chat { Id = 0 }).Generate(); Assert.False(_bot.MessageHandler(message)); }