public void TreatsProtocolsForSameServerIndividiaully() { var record1 = ServerRecord.CreateServer(IPAddress.Loopback.ToString(), 27015, ProtocolTypes.Tcp | ProtocolTypes.Udp); var record2 = ServerRecord.CreateServer(IPAddress.Loopback.ToString(), 27016, ProtocolTypes.Tcp | ProtocolTypes.Udp); serverList.ReplaceList(new[] { record1, record2 }); var nextTcp = serverList.GetNextServerCandidate(ProtocolTypes.Tcp); var nextUdp = serverList.GetNextServerCandidate(ProtocolTypes.Udp); Assert.Equal(record1.EndPoint, nextTcp.EndPoint); Assert.Equal(record1.EndPoint, nextUdp.EndPoint); serverList.TryMark(record1.EndPoint, ProtocolTypes.Tcp, ServerQuality.Bad); nextTcp = serverList.GetNextServerCandidate(ProtocolTypes.Tcp); nextUdp = serverList.GetNextServerCandidate(ProtocolTypes.Udp); Assert.Equal(record2.EndPoint, nextTcp.EndPoint); Assert.Equal(record1.EndPoint, nextUdp.EndPoint); serverList.TryMark(record1.EndPoint, ProtocolTypes.Udp, ServerQuality.Bad); nextTcp = serverList.GetNextServerCandidate(ProtocolTypes.Tcp); nextUdp = serverList.GetNextServerCandidate(ProtocolTypes.Udp); Assert.Equal(record2.EndPoint, nextTcp.EndPoint); Assert.Equal(record2.EndPoint, nextUdp.EndPoint); }
public void DifferentEndPointsAndProtocolsAreNotEqual() { var l = ServerRecord.CreateServer("host", 1, ProtocolTypes.Tcp); var r = ServerRecord.CreateServer("host", 2, ProtocolTypes.WebSocket); Assert.True(l != r); Assert.True(r != l); Assert.False(l == r); Assert.False(r == l); Assert.False(l.Equals(r)); Assert.False(r.Equals(l)); }
public void SameEndPointsAndProtocolsAreEqual() { var l = ServerRecord.CreateServer("host", 1, ProtocolTypes.Tcp); var r = ServerRecord.CreateServer("host", 1, ProtocolTypes.Tcp); Assert.False(l != r); Assert.False(r != l); Assert.True(l == r); Assert.True(r == l); Assert.True(l.Equals(r)); Assert.True(r.Equals(l)); Assert.Equal(l.GetHashCode(), r.GetHashCode()); }
public Task <IEnumerable <ServerRecord> > FetchServerListAsync() => Task.FromResult(ServerRecords.Select(server => ServerRecord.CreateServer(server.Host, server.Port, server.ProtocolTypes)));