Example #1
0
        public void Convert_WithIConvertToActionResult_DelegatesToInterface()
        {
            // Arrange
            var mapper = new ActionResultTypeMapper();

            var expected    = new EmptyResult();
            var returnValue = Mock.Of <IConvertToActionResult>(r => r.Convert() == expected);

            // Act
            var result = mapper.Convert(returnValue, typeof(string));

            // Assert
            Assert.Same(expected, result);
        }
Example #2
0
        public void Convert_WithRegularType_CreatesObjectResult()
        {
            // Arrange
            var mapper = new ActionResultTypeMapper();

            var returnValue = "hello";

            // Act
            var result = mapper.Convert(returnValue, typeof(string));

            // Assert
            var objectResult = Assert.IsType <ObjectResult>(result);

            Assert.Same(returnValue, objectResult.Value);
            Assert.Equal(typeof(string), objectResult.DeclaredType);
        }