Пример #1
0
        public void FromApplicationException_ShouldReturnActionResult_WithStatusCodeFromException(HttpStatusCode code)
        {
            // Given
            var result = PortfolioSubstitute.Result.FromException <string>(code);

            // When
            var actionResult = new ControllerConcrete().FromApplicationException(result);

            // Then
            actionResult.Should().BeOfType <ObjectResult>()
            .Which.StatusCode.Should().Be((int)code);
        }
Пример #2
0
        public void FromApplicationException_ShouldReturnActionResult_WithMessageFromException()
        {
            // Given
            const string message = nameof(message);
            var          result  = PortfolioSubstitute.Result.FromException <string>(HttpStatusCode.NotFound, message);

            // When
            var actionResult = new ControllerConcrete().FromApplicationException(result);

            // Then
            actionResult.Should().BeOfType <ObjectResult>()
            .Which.Value.Should().BeOfType <string>().And.Be(message);
        }
Пример #3
0
        public void FromApplicationException_ShouldReturnProblemActionResult_WhenResultIsSuccessful()
        {
            // Given
            var result = PortfolioSubstitute.Result.FromResource(string.Empty);

            result.Success.Returns(true);

            // When
            var actionResult = new ControllerConcrete().FromApplicationException(result);

            // Then
            actionResult.Should().BeOfType <StatusCodeResult>()
            .Which.StatusCode.Should().Be(500);
        }