public void TestGetMessagesById() { _mediatrMock .Setup(m => m.Send(It.IsAny <GetMessagesByIdCommand>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new GetMessagesByIdResponse() { SmsMessage = new SmsMessages() { MessageContent = "hello", Result = 1, SmsMessagesId = 1 } }); var result = _instance.GetMessagesById(1); var okResult = result.Result as OkObjectResult; Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode); }