Ejemplo n.º 1
0
        public BitString DoStuff(OtherInfoPieces otherInfoPieces, string testPattern)
        {
            // split the pattern into pieces
            var pieces = testPattern.Split("||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            BitString oi = new BitString(0);

            foreach (var piece in pieces)
            {
                var workingPiece = piece.Replace("||", "");
                ConcatenatePieceOntoOtherInfo(otherInfoPieces, workingPiece, ref oi);
            }

            return(oi);
        }
Ejemplo n.º 2
0
        private void ConcatenatePieceOntoOtherInfo(OtherInfoPieces otherInfoPieces, string workingPiece, ref BitString oi)
        {
            if (workingPiece.Equals("uPartyId", StringComparison.OrdinalIgnoreCase))
            {
                oi = oi.ConcatenateBits(ReturnZeroLengthBitStringWhenNull(otherInfoPieces.UPartyId));
                oi = oi.ConcatenateBits(ReturnZeroLengthBitStringWhenNull(otherInfoPieces.DkmNonce));
                return;
            }
            if (workingPiece.StartsWith("literal[", StringComparison.OrdinalIgnoreCase))
            {
                // remove the "literal[]" to get just the hex value
                workingPiece = workingPiece.Replace("literal[", "").Replace("]", "");
                oi           = oi.ConcatenateBits(new BitString(workingPiece));
                return;
            }

            throw new ArgumentException(nameof(workingPiece));
        }
Ejemplo n.º 3
0
        public void TestStuff(OtherInfoPieces otherInfoPieces, string testPattern, BitString expectedBitString)
        {
            var result = _subject.DoStuff(otherInfoPieces, testPattern);

            Assert.AreEqual(expectedBitString.ToHex(), result.ToHex());
        }