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); }
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)); }
public void TestStuff(OtherInfoPieces otherInfoPieces, string testPattern, BitString expectedBitString) { var result = _subject.DoStuff(otherInfoPieces, testPattern); Assert.AreEqual(expectedBitString.ToHex(), result.ToHex()); }