ToString() public method

Gets the serialized bit array.
public ToString ( ) : string
return string
        public void InitializedRandomlyAndThenReinitializedWithString(int length)
        {
            // Arrange
            var random1 = new DeterministicRandom(length);
            var bits = random1.ToString();
            var random2 = new DeterministicRandom(bits);

            // Act
            var cycle11 = Enumerable.Range(1, length).Select(i => random1.NextBool()).ToArray();
            var cycle12 = Enumerable.Range(1, length).Select(i => random1.NextBool()).ToArray();
            var cycle13 = Enumerable.Range(1, length).Select(i => random1.NextBool()).ToArray();

            var cycle21 = Enumerable.Range(1, length).Select(i => random2.NextBool()).ToArray();
            var cycle22 = Enumerable.Range(1, length).Select(i => random2.NextBool()).ToArray();
            var cycle23 = Enumerable.Range(1, length).Select(i => random2.NextBool()).ToArray();

            // Assert
            CollectionAssert.AreEqual(cycle11, cycle12);
            CollectionAssert.AreEqual(cycle12, cycle13);

            CollectionAssert.AreEqual(cycle11, cycle21);
            CollectionAssert.AreEqual(cycle12, cycle22);
            CollectionAssert.AreEqual(cycle13, cycle23);
        }
Beispiel #2
0
        public void InitializedRandomlyAndThenReinitializedWithString(int length)
        {
            // Arrange
            var random1 = new DeterministicRandom(length);
            var bits    = random1.ToString();
            var random2 = new DeterministicRandom(bits);

            // Act
            var cycle11 = Enumerable.Range(1, length).Select(i => random1.NextBool()).ToArray();
            var cycle12 = Enumerable.Range(1, length).Select(i => random1.NextBool()).ToArray();
            var cycle13 = Enumerable.Range(1, length).Select(i => random1.NextBool()).ToArray();

            var cycle21 = Enumerable.Range(1, length).Select(i => random2.NextBool()).ToArray();
            var cycle22 = Enumerable.Range(1, length).Select(i => random2.NextBool()).ToArray();
            var cycle23 = Enumerable.Range(1, length).Select(i => random2.NextBool()).ToArray();

            // Assert
            CollectionAssert.AreEqual(cycle11, cycle12);
            CollectionAssert.AreEqual(cycle12, cycle13);

            CollectionAssert.AreEqual(cycle11, cycle21);
            CollectionAssert.AreEqual(cycle12, cycle22);
            CollectionAssert.AreEqual(cycle13, cycle23);
        }