private void RunForFile(string byteFilename, string xmlFilename) { XmlState xmlSpec = XmlStatePersistor.LoadState(xmlFilename); Assert.NotNull(xmlSpec); bool failed = false; using (StreamReader byteFile = new StreamReader(byteFilename)) { while (!byteFile.EndOfStream) { string[] parts = byteFile.ReadLine().Split(": "); Assert.Equal(2, parts.Length); int index = int.Parse(parts[0]); int count = int.Parse(parts[1]); Macro macroXml = xmlSpec.MacroPool.FirstOrDefault(m => m.Index == index); Assert.NotNull(macroXml); List <byte[]> data = Enumerable.Range(0, count).Select(x => byteFile.ReadLine().HexToByteArray()).ToList(); Assert.Equal(macroXml.Operations.Count, data.Count); for (var i = 0; i < count; i++) { try { MacroOpBase converted = MacroOpManager.CreateFromData(data[i], false); MacroOpBase op = macroXml.Operations[i].ToMacroOp(); if (!Equals(converted, op)) { output.WriteLine("Line {2}\nGot:\n {0}Expected:\n {1}", ToString(converted), ToString(op), i); failed = true; } } catch (Exception e) { output.WriteLine(e.Message + "\n"); failed = true; } } } } Assert.False(failed); }
private void RunForFile(string filename) { string tmpFile = Path.GetTempFileName(); string fullPath = Path.Combine(AppContext.BaseDirectory, filename); XmlState profile = XmlStatePersistor.LoadState(fullPath); Assert.NotNull(profile); Assert.True(XmlStatePersistor.SaveState(tmpFile, profile)); List <string> changes = CompileXmlChanges(CalculateFileVersion(profile.MajorVersion, profile.MinorVersion), fullPath, tmpFile); File.Delete(tmpFile); string res = String.Join(Environment.NewLine, changes); output.WriteLine(res); Assert.Equal("", res); }