public void BuildingRecords() { // After supplying the factory with a record's bytes, the same record must come out var beginRec = new BeginRequestRecord(1); beginRec.Role = Role.Responder; var stdinRec = new StdinRecord(1); stdinRec.Contents.WriteByte(0); stdinRec.Contents.WriteByte(0); BeginRequestRecord builtBeginReqRecord = null; StdinRecord builtStdinRecord = null; var recFactory = new RecordFactory(); foreach (var recData in beginRec.GetBytes()) { builtBeginReqRecord = (BeginRequestRecord)recFactory.Read(recData).SingleOrDefault(); } foreach (var recData in stdinRec.GetBytes()) { builtStdinRecord = (StdinRecord)recFactory.Read(recData).SingleOrDefault(); } Assert.AreEqual(beginRec, builtBeginReqRecord); Assert.AreEqual(stdinRec, builtStdinRecord); }
public void BeginRequestRecordInBlocks() { var beginRec = new BeginRequestRecord(1); BeginRequestRecord builtRecord = null; var byteReader = new RecordFactory(); foreach (var recData in beginRec.GetBytes()) { builtRecord = (BeginRequestRecord)byteReader.Read(recData).SingleOrDefault(); } Assert.AreNotEqual(null, builtRecord); Assert.AreEqual(beginRec, builtRecord); }