public void SerializeXMLTest() { fileAssistant = new FileAssistant(); fileAssistant.SerializationType = "XML"; var aElem = MockObjects.GetAnimationElement(); byte[] bytes = fileAssistant.Serialize(aElem); string xml = new string(Encoding.Unicode.GetChars(bytes)); if (bytes == null || bytes.Length == 0 && XDocument.Parse(xml) == null) { throw new Exception("Assert Fails"); } }
static void Main(string[] args) { if (READ_WRITE_TO_FILE) { WORD_TO_COMPRESS = FileAssistant.ReadFile(READ_FILE_NAME); } var compressionDto = new CompressionDto(); var decompressionDto = new DecompressionDto(); int bufferOffset = 0; View.PrintStartCompressionMessage(); CompressionController.PerformCompression(compressionDto, bufferOffset); View.PrintStartDecompressionMessage(); DecompressionController.PerformDecompression(compressionDto, READ_WRITE_TO_FILE); }
public void DeserializeJSONTest() { fileAssistant = new FileAssistant(); fileAssistant.SerializationType = "JSON"; var aElem = MockObjects.GetAnimationElement(); byte[] bytes = fileAssistant.Serialize(aElem); string xml = new string(Encoding.Unicode.GetChars(bytes)); if (bytes == null || bytes.Length == 0 && XDocument.Parse(xml) == null) { throw new Exception("Assert Fails"); } var aElem2 = fileAssistant.Deserialize <AnimationSingleElement>(bytes); if (aElem.Shape.TypeName != aElem2.Shape.TypeName) { throw new Exception("Assert Fails"); } }
public static void PerformDecompression(CompressionDto compressionDto, bool writeOutputToFile) { DecompressionDto decompressionDto = new DecompressionDto(); foreach (var step in compressionDto.compressionSteps) { if (!IsDecompressedWordEmpty(decompressionDto)) { DecompressWordStep(decompressionDto, step); } else { decompressionDto.DecompressedWord += compressionDto.FirstLetter; } if (writeOutputToFile) { FileAssistant.WriteFile(Program.WRITE_FILE_NAME, decompressionDto.DecompressedWord); } View.PrintDecompressionStage(decompressionDto); } }