Esempio n. 1
0
        /// <summary>
        /// Configures the specified fixture's act step to be aN HTTP request with the specified method, url and body.
        /// </summary>
        /// <param name="fixture">The fixture.</param>
        /// <param name="method">The method.</param>
        /// <param name="url">The URL.</param>
        /// <param name="body">The body.</param>
        /// <returns></returns>
        public static IMvcFunctionalTestFixture WhenCallingRestMethod(this IMvcFunctionalTestFixture fixture, HttpMethod method, string url, object body = null)
        {
            var content = body == null ? null : new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");

            fixture.When(method, url, content);
            return(fixture);
        }
 /// <summary>
 /// Configures the fixture perform the specified HTTP action.
 /// </summary>
 /// <param name="fixture">The fixture.</param>
 /// <param name="method">The HTTP method.</param>
 /// <param name="uri">The URI.</param>
 /// <param name="content">The HTTP content.</param>
 public static IMvcFunctionalTestFixture When(this IMvcFunctionalTestFixture fixture, HttpMethod method, string uri, HttpContent content) =>
 fixture.When(message =>
 {
     message.Method     = method;
     message.RequestUri = new Uri(uri, UriKind.Relative);
     message.Content    = content;
 });
Esempio n. 3
0
 /// <summary>
 /// Configures the request to use the specified string as a bearer token in the authorization header.
 /// </summary>
 /// <param name="fixture">The fixture.</param>
 /// <param name="token">The token.</param>
 /// <returns></returns>
 public static IMvcFunctionalTestFixture HavingBearerToken(this IMvcFunctionalTestFixture fixture, string token) =>
 fixture.When(message => message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token));