コード例 #1
0
        /// <inheritdoc />
        public IAndLocalRedirectTestBuilder ToUrl(Uri localUrl)
        {
            LocationValidator.ValidateUri(
                this.ActionResult,
                localUrl.OriginalString,
                this.ThrowNewRedirectResultAssertionException);

            return(this);
        }
コード例 #2
0
        /// <summary>
        /// Tests whether created result has specific location provided by URI.
        /// </summary>
        /// <param name="location">Expected location as URI.</param>
        /// <returns>The same created test builder.</returns>
        public IAndCreatedTestBuilder AtLocation(Uri location)
        {
            LocationValidator.ValidateUri(
                this.ActionResult,
                location,
                this.ThrowNewCreatedResultAssertionException);

            return(this);
        }
コード例 #3
0
        public void ValidateUrhouldNotThrowExceptionWithProperUriWithCorrectString()
        {
            var actionResultWithLocation = new CreatedResult(TestObjectFactory.GetUri(), "Test");

            LocationValidator.ValidateUri(
                actionResultWithLocation,
                TestObjectFactory.GetUri().OriginalString,
                TestObjectFactory.GetFailingValidationAction());
        }
コード例 #4
0
        public void ValidateUriShouldThrowExceptionWithIncorrectString()
        {
            var actionResultWithLocation = new CreatedNegotiatedContentResult <int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller <WebApiController>().AndProvideTheController());

            LocationValidator.ValidateUri(
                actionResultWithLocation,
                new Uri("http://somehost.com/"),
                TestObjectFactory.GetFailingValidationAction());
        }
コード例 #5
0
        public void ValidateUriShouldNotThrowExceptionWithProperUriWithCorrectString()
        {
            var actionResultWithLocation = new CreatedNegotiatedContentResult <int>(
                TestObjectFactory.GetUri(), 5, MyWebApi.Controller <WebApiController>().AndProvideTheController());

            LocationValidator.ValidateUri(
                actionResultWithLocation,
                TestObjectFactory.GetUri(),
                TestObjectFactory.GetFailingValidationAction());
        }
コード例 #6
0
        /// <inheritdoc />
        public IAndRedirectTestBuilder ToUrl(Uri location)
        {
            var redirrectResult = this.GetRedirectResult <RedirectResult>(Location);

            LocationValidator.ValidateUri(
                this.ActionResult,
                location.OriginalString,
                this.ThrowNewRedirectResultAssertionException);

            return(this);
        }
コード例 #7
0
        /// <inheritdoc />
        public IAndCreatedTestBuilder AtLocation(Uri location)
        {
            var createdResult = this.GetCreatedResult <CreatedResult>(Location);

            LocationValidator.ValidateUri(
                createdResult,
                location.OriginalString,
                this.ThrowNewCreatedResultAssertionException);

            return(this);
        }
コード例 #8
0
        /// <summary>
        /// Tests whether redirect result has specific location provided by URI.
        /// </summary>
        /// <param name="location">Expected location as URI.</param>
        /// <returns>Base test builder.</returns>
        public IBaseTestBuilderWithCaughtException AtLocation(Uri location)
        {
            var redirrectResult = this.GetRedirectResult <RedirectResult>(Location);

            LocationValidator.ValidateUri(
                redirrectResult,
                location,
                this.ThrowNewRedirectResultAssertionException);

            return(this);
        }
        /// <summary>
        /// Tests whether the <see cref="AcceptedResult"/>
        /// has specific location provided by <see cref="Uri"/>.
        /// </summary>
        /// <param name="acceptedTestBuilder">
        /// Instance of <see cref="IAcceptedTestBuilder"/> type.
        /// </param>
        /// <param name="location">Expected location as <see cref="Uri"/>.</param>
        /// <returns>The same <see cref="IAndAcceptedTestBuilder"/>.</returns>
        public static IAndAcceptedTestBuilder AtLocation(
            this IAcceptedTestBuilder acceptedTestBuilder,
            Uri location)
        {
            var actualBuilder = GetAcceptedTestBuilder <AcceptedResult>(acceptedTestBuilder, Location);

            LocationValidator.ValidateUri(
                actualBuilder.ActionResult,
                location.OriginalString,
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder);
        }
コード例 #10
0
        /// <summary>
        /// Tests whether the <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/>
        /// has specific location provided by <see cref="Uri"/>.
        /// </summary>
        /// <param name="baseTestBuilderWithRedirectResult">
        /// Instance of <see cref="IBaseTestBuilderWithRedirectResult{TRedirectResultTestBuilder}"/> type.
        /// </param>
        /// <param name="location">Expected location as <see cref="Uri"/>.</param>
        /// <returns>The same redirect <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/> test builder.</returns>
        public static TRedirectResultTestBuilder ToUrl <TRedirectResultTestBuilder>(
            this IBaseTestBuilderWithRedirectResult <TRedirectResultTestBuilder> baseTestBuilderWithRedirectResult,
            Uri location)
            where TRedirectResultTestBuilder : IBaseTestBuilderWithActionResult
        {
            var actualBuilder = GetActualBuilder(baseTestBuilderWithRedirectResult);

            LocationValidator.ValidateUri(
                actualBuilder.TestContext.MethodResult,
                location.OriginalString,
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder.ResultTestBuilder);
        }
コード例 #11
0
        public void ValidateUrhouldThrowExceptionWithIncorrectString()
        {
            Test.AssertException <NullReferenceException>(
                () =>
            {
                var actionResultWithLocation = new CreatedResult(TestObjectFactory.GetUri(), "Test");

                LocationValidator.ValidateUri(
                    actionResultWithLocation,
                    "http://somehost.com/",
                    TestObjectFactory.GetFailingValidationAction());
            },
                "location to be 'http://somehost.com/' instead received 'http://somehost.com/someuri/1?query=Test'");
        }