public void TestRandomness() { IPAddress[] ips = new IPAddress[4]; for (byte i = 0; i < ips.Length; ++i) { ips[i] = new IPAddress(new byte[] { 192, 168, 0, i }); } IEndpointStrategy endpointStrategy = ServiceActivator <Factory> .Create <IEndpointStrategy>("Random", ips.AsEnumerable()); List <IPAddress> alls = new List <IPAddress>(); for (int i = 0; i < 10000; ++i) { IPAddress nextEndpoint = endpointStrategy.Pick(null); if (!alls.Contains(nextEndpoint)) { alls.Add(nextEndpoint); } } foreach (IPAddress ip in alls) { Assert.IsTrue(alls.Contains(ip)); } }