public void UrlEncodeToBytesThrowsOnInvalidArgs() { Assert.Null(UriQueryUtility.UrlEncodeToBytes(null, 0, 0)); Assert.ThrowsArgumentNull(() => UriQueryUtility.UrlEncodeToBytes(null, 0, 2), "bytes"); Assert.ThrowsArgumentOutOfRange(() => UriQueryUtility.UrlEncodeToBytes(new byte[0], -1, 0), "offset", null); Assert.ThrowsArgumentOutOfRange(() => UriQueryUtility.UrlEncodeToBytes(new byte[0], 2, 0), "offset", null); Assert.ThrowsArgumentOutOfRange(() => UriQueryUtility.UrlEncodeToBytes(new byte[0], 0, -1), "count", null); Assert.ThrowsArgumentOutOfRange(() => UriQueryUtility.UrlEncodeToBytes(new byte[0], 0, 2), "count", null); }
public void HttpSelfHostConfiguration_ClientCredentialType_RoundTrips() { HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost"); Assert.Reflection.EnumPropertyWithoutIllegalValueCheck <HttpSelfHostConfiguration, HttpClientCredentialType>( config, c => c.ClientCredentialType, expectedDefaultValue: HttpClientCredentialType.None, roundTripTestValue: HttpClientCredentialType.Windows); // now let us check the illegal value differently config.ClientCredentialType = (HttpClientCredentialType)999; Assert.ThrowsArgumentOutOfRange( () => { new HttpSelfHostServer(config).OpenAsync().Wait(); }, "value", null, false, 999); }