示例#1
0
        public async Task TestDeleteMessageByMessageId_Success_OkResponse()
        {
            // Arrange
            var id = 1;

            mockMessagesRepository.Setup(a => a.DeleteMessageByMessageId(It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(new BaseResult <bool>()
            {
                Result = true
            }));
            //Act
            var result = await mockMessageController.DeleteMessageByMessageId(id);

            BaseResult <bool> finalResult = (result as Microsoft.AspNetCore.Mvc.OkObjectResult).Value as BaseResult <bool>;

            //Assert
            Assert.AreEqual(((Microsoft.AspNetCore.Mvc.ObjectResult)result).StatusCode, 200);
            Assert.IsNotNull(finalResult);
            Assert.IsTrue(!finalResult.IsError);
        }