public void BitIs1WhenTokenIsNumber()
        {
            BinarySequenceHashBuilder hash = new BinarySequenceHashBuilder();

            hash.AppendOneSequence();

            Assert.AreEqual(1, hash.GetBytes()[0]);
        }
        public void BitIs0WhenTokenIsAlpha()
        {
            BinarySequenceHashBuilder hash = new BinarySequenceHashBuilder();

            hash.AppendZeroToSequence();

            Assert.AreEqual(0, hash.GetBytes()[0]);
        }
        public void BitsMarkedInSequenceWhenMultipleTokensSet()
        {
            BinarySequenceHashBuilder hash = new BinarySequenceHashBuilder();

            hash.AppendOneSequence();
            hash.AppendZeroToSequence();
            hash.AppendOneSequence();
            hash.AppendZeroToSequence();

            byte[] bytes = hash.GetBytes();

            Assert.AreEqual(10 /* think binary flags */, bytes[0]);
        }
        public void HashesAreEqualWhenEquivalentHashesAreCompared()
        {
            BinarySequenceHashBuilder hash1 = new BinarySequenceHashBuilder();

            for (int i = 0; i < Byte.MaxValue; i++)
            {
                if (i % 3 == 0)
                {
                    hash1.AppendOneSequence();
                }
                else if (i % 2 == 0)
                {
                    hash1.AppendZeroToSequence();
                }
            }

            BinarySequenceHashBuilder hash2 = new BinarySequenceHashBuilder(hash1.GetBytes());

            Assert.IsTrue(hash1 == hash2, "==");
            Assert.IsTrue(hash1.Equals(hash2), ".Equals");
        }
        public void SanityCheckBitsMarkedWhenAllBitsUsed()
        {
            BinarySequenceHashBuilder hash = new BinarySequenceHashBuilder();
            int lastMarkerIndex = BinarySequenceHashBuilder.SEQUENCE_BYTE_LENGTH - 2;

            for (int i = 0; i < Byte.MaxValue; i++)
            {
                hash.AppendOneSequence();
            }

            byte[] bytes = hash.GetBytes();

            for (int i = 0; i < lastMarkerIndex; i++)
            {
                if (bytes[i] != 0xFF)
                {
                    Assert.Fail();
                    break;
                }
            }

            Assert.AreEqual(127, bytes[lastMarkerIndex]);
        }