public static BindingInformation Parse(string value) { var bindingInformation = new BindingInformation(); if (string.IsNullOrEmpty(value)) { return bindingInformation; } var values = value.Split(':'); if (values.Length >= 1) { bindingInformation.IpAddress = values[0]; } if (values.Length >= 2) { bindingInformation.Port = Convert.ToInt32(values[1]); } if (values.Length >= 3) { bindingInformation.HostName = values[2]; } return bindingInformation; }
public void Constructor_ShouldSetDefaults() { var information = new BindingInformation(); Assert.Equal("*", information.IpAddress); Assert.Equal(80, information.Port); Assert.Equal(null, information.HostName); }
public void ToString_BuildsTheCorrectStringRepresentingTheBinding() { var information = new BindingInformation(); information.Port = 8080; information.IpAddress = "192.168.1.1"; information.HostName = "mysite.com"; var expected = "192.168.1.1:8080:mysite.com"; var actual = information.ToString(); Assert.Equal(expected, actual); }