public void ConstructorThrowsOnNull() { Mock <HttpMessageHandler> mockHandler = new Mock <HttpMessageHandler>(); Assert.ThrowsArgumentNull(() => new HttpServer((HttpConfiguration)null, mockHandler.Object), "configuration"); Assert.ThrowsArgumentNull(() => new HttpServer(new HttpConfiguration(), null), "dispatcher"); }
public void Constructor_GuardClauses() { HttpRequestMessage request = new HttpRequestMessage(); Assert.ThrowsArgumentNull(() => new HttpRequestMessageWrapper(virtualPathRoot: null, httpRequest: request), "virtualPathRoot"); Assert.ThrowsArgumentNull(() => new HttpRequestMessageWrapper(String.Empty, httpRequest: null), "httpRequest"); }
public void TryReadQueryAsThrowsWithNull() { object value; Assert.ThrowsArgumentNull(() => ((Uri)null).TryReadQueryAs(TestType, out value), "address"); Assert.ThrowsArgumentNull(() => TestAddress.TryReadQueryAs(null, out value), "type"); }
public void OnAuthorization_IfContextParameterIsNull_ThrowsException() { Assert.ThrowsArgumentNull(() => { _attribute.OnAuthorization(actionContext: null); }, "actionContext"); }
public void HandleUnauthorizedRequest_IfContextParameterIsNull_ThrowsArgumentNullException() { Assert.ThrowsArgumentNull(() => { _attribute.HandleUnauthorizedRequestPublic(context: null); }, "actionContext"); }
public void ReadFromStreamAsync_ThrowsOnNull() { TFormatter formatter = new TFormatter(); Assert.ThrowsArgumentNull(() => { formatter.ReadFromStreamAsync(null, Stream.Null, null, null); }, "type"); Assert.ThrowsArgumentNull(() => { formatter.WriteToStreamAsync(typeof(object), null, null, null, null); }, "stream"); }
public void CanWriteAsThrowsWithNullContent() { MockMediaTypeFormatter formatter = new MockMediaTypeFormatter(); MediaTypeHeaderValue mediaType = null; Assert.ThrowsArgumentNull(() => formatter.CanWriteAs(typeof(int), null, out mediaType), "mediaType"); }
public void ReadFromStreamThrowsOnNull() { TestFormUrlEncodedMediaTypeFormatter formatter = new TestFormUrlEncodedMediaTypeFormatter(); Assert.ThrowsArgumentNull(() => { formatter.ReadFromStreamAsync(null, Stream.Null, null, null); }, "type"); Assert.ThrowsArgumentNull(() => { formatter.ReadFromStreamAsync(typeof(object), null, null, null); }, "stream"); }
public void ReadAsHttpRequestMessageVerifyArguments() { Assert.ThrowsArgumentNull(() => HttpContentMessageExtensions.ReadAsHttpRequestMessageAsync(null), "content"); Assert.ThrowsArgument(() => new ByteArrayContent(new byte[] { }).ReadAsHttpRequestMessageAsync(), "content"); Assert.ThrowsArgument(() => new StringContent(String.Empty).ReadAsHttpRequestMessageAsync(), "content"); Assert.ThrowsArgument(() => new StringContent(String.Empty, Encoding.UTF8, "application/http").ReadAsHttpRequestMessageAsync(), "content"); Assert.ThrowsArgument(() => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpResponseMediaType; content.ReadAsHttpRequestMessageAsync(); }, "content"); Assert.ThrowsArgumentNull(() => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpRequestMediaType; content.ReadAsHttpRequestMessageAsync(null); }, "uriScheme"); Assert.ThrowsArgument(() => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpRequestMediaType; content.ReadAsHttpRequestMessageAsync("i n v a l i d"); }, "uriScheme"); Assert.ThrowsArgumentGreaterThanOrEqualTo(() => { HttpContent content = new StringContent(String.Empty); content.Headers.ContentType = ParserData.HttpRequestMediaType; content.ReadAsHttpRequestMessageAsync(Uri.UriSchemeHttp, ParserData.MinBufferSize - 1); }, "bufferSize", ParserData.MinBufferSize.ToString(), ParserData.MinBufferSize - 1); }
public void FindWriter_ThrowsOnNullType() { MediaTypeFormatterCollection collection = new MediaTypeFormatterCollection(); MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("text/test"); Assert.ThrowsArgumentNull(() => collection.FindWriter(type: null, mediaType: mediaType), "type"); }
public void TryGetValueThrowsOnNullKey() { IDictionary <string, object> dict = new Dictionary <string, object>(); string value; Assert.ThrowsArgumentNull(() => dict.TryGetValue <string>(null, out value), "key"); }
public void ReadAsMultipartAsync_DetectsNonMultipartContent() { Assert.ThrowsArgumentNull(() => HttpContentMultipartExtensions.IsMimeMultipartContent(null), "content"); Assert.ThrowsArgument(() => new ByteArrayContent(new byte[0]).ReadAsMultipartAsync().Result, "content"); Assert.ThrowsArgument(() => new StringContent(String.Empty).ReadAsMultipartAsync().Result, "content"); Assert.ThrowsArgument(() => new StringContent(String.Empty, Encoding.UTF8, "multipart/form-data").ReadAsMultipartAsync().Result, "content"); }
public void SetDefaultContentHeaders_ThrowsOnNullHeaders() { MockMediaTypeFormatter formatter = new MockMediaTypeFormatter(); Type type = typeof(object); Assert.ThrowsArgumentNull(() => formatter.SetDefaultContentHeaders(type, null, TestMediaTypeHeader), "headers"); }
public void SupportedMediaTypes_AddThrowsWithNullMediaType() { MockMediaTypeFormatter formatter = new MockMediaTypeFormatter(); Collection <MediaTypeHeaderValue> supportedMediaTypes = formatter.SupportedMediaTypes; Assert.ThrowsArgumentNull(() => supportedMediaTypes.Add(null), "item"); }
public void SetSerializer2_ThrowsWithNullType() { XmlMediaTypeFormatter formatter = new XmlMediaTypeFormatter(); XmlObjectSerializer xmlObjectSerializer = new DataContractSerializer(typeof(string)); Assert.ThrowsArgumentNull(() => { formatter.SetSerializer(null, xmlObjectSerializer); }, "type"); }
public void SetDefaultContentHeaders_ThrowsOnNullType() { MockMediaTypeFormatter formatter = new MockMediaTypeFormatter(); HttpContentHeaders contentHeaders = FormattingUtilities.CreateEmptyContentHeaders(); Assert.ThrowsArgumentNull(() => formatter.SetDefaultContentHeaders(null, contentHeaders, TestMediaTypeHeader), "type"); }
public void SetResolverCommonServiceLocatorThrowsOnNull() { HttpConfiguration config = new HttpConfiguration(); DependencyResolver resolver = new DependencyResolver(config); Assert.ThrowsArgumentNull(() => resolver.SetResolver((object)null), "commonServiceLocator"); }
public void SetResolverIDependencyResolverThrowsOnNull() { HttpConfiguration config = new HttpConfiguration(); DependencyResolver resolver = new DependencyResolver(config); Assert.ThrowsArgumentNull(() => resolver.SetResolver((IDependencyResolver)null), "resolver"); }
public void ConstructorThrowsOnNull() { Mock <HttpControllerDispatcher> controllerDispatcherMock = new Mock <HttpControllerDispatcher>(); Assert.ThrowsArgumentNull(() => new HttpServer((HttpConfiguration)null, controllerDispatcherMock.Object), "configuration"); Assert.ThrowsArgumentNull(() => new HttpServer(new HttpConfiguration(), null), "dispatcher"); }
public void SetResolverFuncThrowsOnNull() { HttpConfiguration config = new HttpConfiguration(); DependencyResolver resolver = new DependencyResolver(config); Assert.ThrowsArgumentNull(() => resolver.SetResolver(null, _ => null), "getService"); Assert.ThrowsArgumentNull(() => resolver.SetResolver(_ => null, null), "getServices"); }
public void IsMimeMultipartContentVerifyArguments() { Assert.ThrowsArgumentNull(() => { HttpContent content = null; HttpContentMultipartExtensions.IsMimeMultipartContent(content); }, "content"); }
public void IsHttpResponseMessageContentVerifyArguments() { Assert.ThrowsArgumentNull(() => { HttpContent content = null; HttpContentMessageExtensions.IsHttpResponseMessageContent(content); }, "content"); }
public void Initializer_Throws_With_Null() { // Arrange var config = new HttpConfiguration(); // Act & Assert Assert.ThrowsArgumentNull(() => config.Initializer = null, "value"); }
public void ParseBufferThrowsOnNullBuffer() { ICollection <KeyValuePair <string, string> > collection; FormUrlEncodedParser parser = CreateParser(128, out collection); int bytesConsumed = 0; Assert.ThrowsArgumentNull(() => { parser.ParseBuffer(null, 0, ref bytesConsumed, false); }, "buffer"); }
public void FindAllContentTypeMediaTypeThrows() { Assert.ThrowsArgumentNull(() => { HttpContentCollectionExtensions.FindAllContentType(null, new MediaTypeHeaderValue("text/plain")); }, "contents"); IEnumerable <HttpContent> content = HttpContentCollectionExtensionsTests.CreateContent(); Assert.ThrowsArgumentNull(() => { HttpContentCollectionExtensions.FindAllContentType(content, (MediaTypeHeaderValue)null); }, "contentType"); }
public void DependencyResolver_GuardClauses() { // Arrange var config = new HttpConfiguration(); // Act & assert Assert.ThrowsArgumentNull(() => config.DependencyResolver = null, "value"); }
public void SelectResponseMediaTypeFormatter_ThrowsOnNull() { MockContentNegotiator negotiator = new MockContentNegotiator(); HttpRequestMessage request = new HttpRequestMessage(); MockMediaTypeFormatter formatter = new MockMediaTypeFormatter(); Assert.ThrowsArgumentNull(() => negotiator.SelectResponseMediaTypeFormatter(matches: null), "matches"); }
public void ConvertToThrowsIfTypeIsNull() { // Arrange ValueProviderResult vpr = new ValueProviderResult("x", null, CultureInfo.InvariantCulture); // Act & Assert Assert.ThrowsArgumentNull( delegate { vpr.ConvertTo(null); }, "type"); }
public void GetServicesThrowsOnNull() { // Arrange HttpConfiguration config = new HttpConfiguration(); DependencyResolver resolver = new DependencyResolver(config, null); // Act Assert.ThrowsArgumentNull(() => resolver.GetServices(null), "serviceType"); }
public void ReadAsMultipartAsync_NullStreamProviderThrows() { HttpContent content = CreateContent("---"); Assert.ThrowsArgumentNull(() => { content.ReadAsMultipartAsync(null); }, "streamProvider"); }