public static void TearDown()
 {
     CryptoRandom?.Dispose();
     CryptoRandom = null;
     Random?.Dispose();
     Random = null;
 }
Example #2
0
 public Connection(IThreadsafeRandom Random, NodeBase FromNode, NodeBase ToNode, TimeSpan MinLatency, TimeSpan MaxLatency)
 {
     _random       = Random;
     this.FromNode = FromNode;
     this.ToNode   = ToNode;
     _minLatency   = MinLatency;
     _maxLatency   = MaxLatency;
 }
Example #3
0
 protected NodeBase(IThreadsafeRandom Random, int Id, string Name, string RegionName)
 {
     this.Random     = Random;
     this.Id         = Id;
     this.Name       = Name;
     this.RegionName = RegionName;
     Values          = new ConcurrentDictionary <string, string>();
     Online          = true;
 }
Example #4
0
        public static void Shuffle <T>(this IList <T> Items, IThreadsafeRandom Random)
        {
            // Use the Fischer-Yates algorithm.
            // See https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
            var maxIndex = Items.Count - 1;

            for (var index = maxIndex; index > 0; index--)
            {
                var swapIndex = Random.Next(0, index + 1);
                var temp      = Items[index];
                Items[index]     = Items[swapIndex];
                Items[swapIndex] = temp;
            }
        }
Example #5
0
 public QuorumNode(IThreadsafeRandom Random, int Id, string Name, string RegionName, int RequiredVotes, bool ReadRepair) :
     base(Random, Id, Name, RegionName)
 {
     _requiredVotes = RequiredVotes;
     _readRepair    = ReadRepair;
 }
Example #6
0
 public XmlGenerator(IThreadsafeRandom Random)
 {
     _random            = Random;
     _elementNames      = new Stack <string>();
     _actionPercentages = new[] { 60, 80 }; // Close, open, write element.
 }
Example #7
0
 public Client(IThreadsafeRandom Random, int Id, string Name, string RegionName) :
     base(Random, Id, Name, RegionName)
 {
 }
 public void SetUp()
 {
     Random       = new ThreadsafeRandom();
     CryptoRandom = new ThreadsafeCryptoRandom();
 }