public void Cast_GivenProtocolId_ReturnsString() { var pid = new ProtocolId("/test/pid"); var pids = (string)pid; Assert.That(pids, Is.EqualTo(pid.ToString())); }
public static Func <string, bool> SemverMatcher(ProtocolId @base) { var parts = @base.ToString().Split('/'); SemVersion version; if (!SemVersion.TryParse(parts.Last(), out version)) { throw new ArgumentException("Not a valid semantic version in protocol id", nameof(@base)); } return(check => { var chparts = check.Split('/'); if (chparts.Length != parts.Length) { return false; } for (var i = 0; i < chparts.Length - 1; i++) { if (parts[i] != chparts[i]) { return false; } } SemVersion chvers; if (!SemVersion.TryParse(chparts.Last(), out chvers)) { return false; } return version.Major == chvers.Major && version.Minor >= chvers.Minor; }); }
private void Save() { using (var w = new StreamWriter(ConfigFileName, false, Encoding.UTF8)) { w.WriteLine("[server]"); w.Write("protocol = "); w.WriteLine(Protocol.ToString().ToLower()); w.Write("address = "); w.WriteLine(Address); w.Write("port = "); w.WriteLine(Port); w.WriteLine("[security]"); w.Write("sym_algorithm = "); w.WriteLine(SymAlgorithm.ToString().ToLower()); w.Write("asym_algorithm = "); w.WriteLine(AsymAlgorithm.ToString().ToLower()); w.Write("sym_key_size = "); w.WriteLine(SymAlgorithmKeySize); w.Write("asym_key_size = "); w.WriteLine(AsymAlgorithmKeySize); w.WriteLine("[socket]"); w.Write("ipv6 = "); w.WriteLine(UseIPv6 ? 1 : 0); w.Write("send_timeout = "); w.WriteLine(SocketSendTimeout); w.Write("send_buffer_size = "); w.WriteLine(SocketSendBufferSize); w.Write("recv_buffer_size = "); w.WriteLine(SocketReceiveBufferSize); w.Write("backlog = "); w.WriteLine(SocketBacklog); w.WriteLine("[misc]"); w.Write("update_sleep = "); w.WriteLine(UpdateSleep); } }
public void Save() { using (var w = new StreamWriter(ConfigFileName, false, Encoding.UTF8)) { w.WriteLine("[client]"); w.Write("protocol = "); w.WriteLine(Protocol.ToString().ToLower()); w.Write("host = "); w.WriteLine(Host); w.Write("port = "); w.WriteLine(Port); w.Write("login = "******"password = "******"" ? "" : Encrypt(Password)); w.Write("remember = "); w.WriteLine(Remember ? 1 : 0); w.WriteLine("[security]"); w.Write("sym_algorithm = "); w.WriteLine(SymAlgorithm.ToString().ToLower()); w.Write("asym_algorithm = "); w.WriteLine(AsymAlgorithm.ToString().ToLower()); w.WriteLine("[socket]"); w.Write("ipv6 = "); w.WriteLine(UseIPv6 ? 1 : 0); w.Write("send_timeout = "); w.WriteLine(SocketSendTimeout); w.Write("send_buffer_size = "); w.WriteLine(SocketSendBufferSize); w.Write("recv_buffer_size = "); w.WriteLine(SocketReceiveBufferSize); w.WriteLine("[misc]"); w.Write("update_sleep = "); w.WriteLine(UpdateSleep); } }
public void Constructor_GivenProtocol_ReturnsValidProtocolId() { var pid = new ProtocolId("/test/pid"); Assert.That(pid.ToString(), Is.EqualTo("/test/pid")); }