public void ToBinary_ShouldMatchSourceBinary_Version1BigEndian() { var binary = MessageScriptBinary.FromFile("TestResources\\Version1BigEndian.bmd"); var script = MessageScript.FromBinary(binary); var newBinary = script.ToBinary(); Compare(binary, newBinary); }
public void ToStream_StreamNotNullOrEmptyAndLengthEqualToFileSize_Version1() { var script = MessageScriptBinary.FromFile("TestResources\\Version1.bmd"); var stream = script.ToStream(); Assert.IsNotNull(stream); Assert.AreNotEqual(0, stream.Length); Assert.AreEqual(script.Header.FileSize, stream.Length); }
/// <summary> /// Deserializes and creates a <see cref="MessageScript"/> from a file. /// </summary> public static MessageScript FromFile(string path, FormatVersion version = FormatVersion.Version1, Encoding encoding = null) { if (path == null) { throw new ArgumentNullException(nameof(path)); } var binary = MessageScriptBinary.FromFile(path); return(FromBinary(binary, version, encoding)); }
public void ToFile_ResultShouldPassIntegrityCheck_Version1BigEndian() { try { var script = MessageScriptBinary.FromFile("TestResources\\Version1BigEndian.bmd"); script.ToFile("TestResources\\Version1BigEndian_ToFile.bmd"); script = MessageScriptBinary.FromFile("TestResources\\Version1BigEndian_ToFile.bmd"); PerformIntegrityCheckForVersion1BigEndian(script); } finally { File.Delete("TestResources\\Version1BigEndian_ToFile.bmd"); } }
public void FromFile_NoException_Batch() { foreach (var path in Directory.EnumerateFiles("TestResources\\Batch\\", "*.bmd")) { var script = MessageScriptBinary.FromFile(path); PrintSpeakerIdsIfHigherThanTotalSpeakers(script); if (script.SpeakerTableHeader.ExtDataOffset != 0) { Trace.WriteLine($"{nameof( MessageScriptBinary )}.{nameof( script.SpeakerTableHeader )}.{nameof( script.SpeakerTableHeader.ExtDataOffset )} = {script.SpeakerTableHeader.ExtDataOffset}"); } if (script.SpeakerTableHeader.Reserved != 0) { Trace.WriteLine($"{nameof( MessageScriptBinary )}.{nameof( script.SpeakerTableHeader )}.{nameof( script.SpeakerTableHeader.Reserved )} = {script.SpeakerTableHeader.Reserved}"); } } }
public void FromBinary_ShouldNotThrow_Version1BigEndian() { var binary = MessageScriptBinary.FromFile("TestResources\\Version1BigEndian.bmd"); var script = MessageScript.FromBinary(binary); }
public void FromFile_ShouldThrowException_InvalidFileFormat() { Assert.ThrowsException <InvalidDataException>(() => MessageScriptBinary.FromFile("TestResources\\dummy_big.bin")); }
public void FromFile_ShouldThrowException_EmptyStringArgument() { Assert.ThrowsException <ArgumentException>(() => MessageScriptBinary.FromFile(String.Empty)); }
public void FromFile_ShouldThrowException_NullArgument() { Assert.ThrowsException <ArgumentNullException>(() => MessageScriptBinary.FromFile(null)); }
public void FromFile_ShouldPassIntegrityCheck_Version1BigEndianWithVersion1Argument() { var script = MessageScriptBinary.FromFile("TestResources\\Version1BigEndian.bmd", BinaryFormatVersion.Version1); PerformIntegrityCheckForVersion1BigEndian(script); }
public void FromFile_ShouldPassIntegrityCheck_Version1WithUnknownVersionArgument() { var script = MessageScriptBinary.FromFile("TestResources\\Version1.bmd"); PerformIntegrityCheckForVersion1(script); }