using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Xunit; namespace FluentUriBuilder.Tests { public class ThrowsTests { [Fact] public void ThrowsArgNull() { var tstObj = new UriBuilder(); Assert.Throws(() => tstObj.WithParameter(string.Empty, string.Empty)); Assert.Throws(() => tstObj.WithFragment(string.Empty, string.Empty)); Assert.Throws(() => tstObj.WithPathSegment(null)); Assert.Throws(() => tstObj.WithScheme(null)); Assert.Throws(() => tstObj.WithHost(null)); Assert.Throws(() => tstObj.WithParameter((IEnumerable>)null)); Assert.Throws(() => tstObj.WithFragment(fragmentDictionary: null)); Assert.Throws(() => tstObj.WithPort(-1)); UriBuilder nullPtr = null; Assert.Throws(() => nullPtr.WithFragment("yo", "dawg")); Assert.Throws(() => nullPtr.WithFragment(new Dictionary())); Assert.Throws(() => nullPtr.WithParameter("yo", "dawg")); Assert.Throws(() => nullPtr.WithPathSegment("yo")); Assert.Throws(() => nullPtr.WithScheme("yo")); Assert.Throws(() => nullPtr.WithFragment("yo")); Assert.Throws(() => nullPtr.WithoutDefaultPort()); Assert.Throws(() => nullPtr.WithoutDefaultPort()); Assert.Throws(() => nullPtr.WithPort(1)); Assert.Throws(() => nullPtr.WithHost("yo")); Assert.Throws(() => nullPtr.UseHttps()); } } }