/// <summary> /// Writes the CGM commands to the given stream- /// </summary> /// <param name="stream">The stream to write the content to.</param> public void WriteFile(Stream stream) { ResetMetaDefinitions(); using var writer = new DefaultBinaryWriter(stream, this); foreach (var command in _commands) { writer.WriteCommand(command); } _messages.AddRange(writer.Messages); }
private void Test(Action <IBinaryWriter> writerAction, Action <IBinaryReader> readerAction) { _stream.SetLength(0); var command = new TestCommand(writerAction, readerAction); _writer.WriteCommand(command); _stream.Position = 0; _commandFactory.Setup(c => c.CreateCommand(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CgmFile>())).Returns(command); _reader.ReadCommands(); if (_reader.Messages.Any()) { Assert.Fail(string.Join("\r\n", _reader.Messages.Select(m => m.ToString()).ToArray())); } }