public void NotEquals_EmptyHostStringAndNonNullHostString() { // Arrange var hostString = new HostString("example.com"); // Act and Assert Assert.NotEqual(hostString, new HostString(string.Empty)); }
public void NotEquals_DefaultHostStringAndNonNullHostString() { // Arrange var hostString = new HostString("example.com"); // Act and Assert Assert.NotEqual(default(HostString), hostString); }
public void Port_ExtractsInvalidPortFromValue(string sourceValue) { // Arrange var hostString = new HostString(sourceValue); // Act var result = hostString.Port; // Assert Assert.Null(result); }
public void Port_ExtractsPortFromValue(string sourceValue, int?expectedPort) { // Arrange var hostString = new HostString(sourceValue); // Act var result = hostString.Port; // Assert Assert.Equal(expectedPort, result); }
public void Domain_ExtractsHostFromValue(string sourceValue, string expectedDomain) { // Arrange var hostString = new HostString(sourceValue); // Act var result = hostString.Host; // Assert Assert.Equal(expectedDomain, result); }
public void Ctor_CreatesFromHostAndPort(string sourceHost, int sourcePort, string expectedHost, int expectedPort) { // Arrange var hostString = new HostString(sourceHost, sourcePort); // Act var host = hostString.Host; var port = hostString.Port; // Assert Assert.Equal(expectedHost, host); Assert.Equal(expectedPort, port); }
public void ImplicitStringConverters_WorksWithAdd() { var scheme = "http"; var host = new HostString("localhost:80"); var pathBase = new PathString("/base"); var path = new PathString("/path"); var query = new QueryString("?query"); var fragment = new FragmentString("#frag"); var result = scheme + "://" + host + pathBase + path + query + fragment; Assert.Equal("http://localhost:80/base/path?query#frag", result); result = pathBase + path + query + fragment; Assert.Equal("/base/path?query#frag", result); result = path + "text"; Assert.Equal("/pathtext", result); }
public void HostMatchThrowsForBadPort() { Assert.Throws <FormatException>(() => HostString.MatchesAny("example.com:1abc", new StringSegment[] { "example.com" })); }
[InlineData("::1", "::1")] // Brackets are added to the host before the comparison public void HostDoesntMatch(string host, string pattern) { Assert.False(HostString.MatchesAny(host, new StringSegment[] { pattern })); }
public void HostMatches(string host, string pattern) { Assert.True(HostString.MatchesAny(host, new StringSegment[] { pattern })); }