コード例 #1
0
        public void ValidateAndGetWellFormedUriStringShouldThrowExceptionWithIncorrectString()
        {
            string uriAsString = "http://somehost!@#?Query==true";

            var uri = LocationValidator.ValidateAndGetWellFormedUriString(
                uriAsString,
                TestObjectFactory.GetFailingValidationAction());
        }
コード例 #2
0
        /// <summary>
        /// Adds request location to the built HTTP request message.
        /// </summary>
        /// <param name="location">Expected location as string.</param>
        /// <returns>The same HTTP request message builder.</returns>
        public IAndHttpRequestMessageBuilder WithRequestUri(string location)
        {
            this.requestMessage.RequestUri = LocationValidator.ValidateAndGetWellFormedUriString(
                location,
                this.ThrowNewInvalidHttpRequestMessageException);

            return(this);
        }
コード例 #3
0
        /// <inheritdoc />
        public IAndHttpRequestBuilder WithLocation(string location)
        {
            var uri = LocationValidator.ValidateAndGetWellFormedUriString(
                location,
                this.ThrowNewInvalidHttpRequestMessageException);

            return(this.WithLocation(uri));
        }
コード例 #4
0
 /// <summary>
 /// Pridá umiestnenie žiadosti do správy HTTP.
 /// </summary>
 /// <param name="location">Expected location as string.</param>
 /// <returns>The same HTTP request message builder.</returns>
 public IAndHttpRequestMessageBuilder WithRequestUri(string location)
 {
     this.requestMessage.RequestUri = LocationValidator.ValidateAndGetWellFormedUriString(
         location,
         this.ThrowNewInvalidHttpRequestMessageException);
     Reporter.Info("Uri: " + string.Format("{0}{1}", MyWebApi.BaseAddress, requestMessage.RequestUri.ToString()), CodeBlockType.Label);
     return(this);
 }
コード例 #5
0
        /// <inheritdoc />
        public IAndLocalRedirectTestBuilder ToUrl(string localUrl)
        {
            var uri = LocationValidator.ValidateAndGetWellFormedUriString(
                localUrl,
                this.ThrowNewRedirectResultAssertionException);

            return(this.ToUrl(uri));
        }
コード例 #6
0
        /// </summary>
        /// <param name="location">Expected location as URI.</param>
        /// <returns>The same HTTP request message builder.</returns>
        public IAndHttpRequestMessageBuilder WithRequestUri(string location, string response, string path, string withAction)
        {
            getTestedValue = this.GetTestedValueWithMessage(response, path);
            this.requestMessage.RequestUri = LocationValidator.ValidateAndGetWellFormedUriString(
                location + "/" + getTestedValue + "/" + withAction,
                this.ThrowNewInvalidHttpRequestMessageException);

            return(this);
        }
コード例 #7
0
        public void ValidateAndGetWellFormedUriStringShouldReturnProperUriWithCorrectString()
        {
            string uriAsString = "http://somehost.com/someuri/1?query=Test";

            var uri = LocationValidator.ValidateAndGetWellFormedUriString(
                uriAsString,
                TestObjectFactory.GetFailingValidationAction());

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

            var uri = LocationValidator.ValidateAndGetWellFormedUriString(
                location,
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder.AtLocation(uri));
        }
コード例 #9
0
        public void ValidateAndGetWellFormedUriStringShouldThrowExceptionWithIncorrectString()
        {
            string uriAsString = "http://somehost!@#?Query==true";

            var exception = Assert.Throws <NullReferenceException>(() =>
            {
                var uri = LocationValidator.ValidateAndGetWellFormedUriString(
                    uriAsString,
                    TestObjectFactory.GetFailingValidationAction());
            });

            Assert.Equal("location to be URI valid instead received http://somehost!@#?Query==true", exception.Message);
        }
コード例 #10
0
        /// <summary>
        /// Tests whether the <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/>
        /// has specific location provided by string.
        /// </summary>
        /// <param name="baseTestBuilderWithRedirectResult">
        /// Instance of <see cref="IBaseTestBuilderWithRedirectResult{TRedirectResultTestBuilder}"/> type.
        /// </param>
        /// <param name="location">Expected location as string.</param>
        /// <returns>The same redirect <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/> test builder.</returns>
        public static TRedirectResultTestBuilder ToUrl <TRedirectResultTestBuilder>(
            this IBaseTestBuilderWithRedirectResult <TRedirectResultTestBuilder> baseTestBuilderWithRedirectResult,
            string location)
            where TRedirectResultTestBuilder : IBaseTestBuilderWithActionResult
        {
            var actualBuilder = GetActualBuilder(baseTestBuilderWithRedirectResult);

            var uri = LocationValidator.ValidateAndGetWellFormedUriString(
                location,
                actualBuilder.ThrowNewFailedValidationException);

            return(baseTestBuilderWithRedirectResult.ToUrl(uri));
        }
コード例 #11
0
        public void ValidateAndGetWellFormedUrtringShouldThrowExceptionWithIncorrectString()
        {
            string uriAsString = "http://somehost!@#?Query==true";

            Test.AssertException <NullReferenceException>(
                () =>
            {
                LocationValidator.ValidateAndGetWellFormedUriString(
                    uriAsString,
                    TestObjectFactory.GetFailingValidationAction());
            },
                "location to be URI valid instead received 'http://somehost!@#?Query==true'");
        }
コード例 #12
0
        /// <summary>
        /// Tests whether created result has specific location provided by string.
        /// </summary>
        /// <param name="location">Expected location as string.</param>
        /// <returns>The same created test builder.</returns>
        public IAndCreatedTestBuilder AtLocation(string location)
        {
            var uri = LocationValidator.ValidateAndGetWellFormedUriString(location, this.ThrowNewCreatedResultAssertionException);

            return(this.AtLocation(uri));
        }
コード例 #13
0
        /// <summary>
        /// Tests whether redirect result has specific location provided by string.
        /// </summary>
        /// <param name="location">Expected location as string.</param>
        /// <returns>Base test builder.</returns>
        public IBaseTestBuilderWithCaughtException AtLocation(string location)
        {
            var uri = LocationValidator.ValidateAndGetWellFormedUriString(location, this.ThrowNewRedirectResultAssertionException);

            return(this.AtLocation(uri));
        }