Exemplo n.º 1
0
        public static void SaveToFile(String filePath, KspObject kspObjTree)
        {
            var craftToken  = KspObjectWriter.WriteObject(kspObjTree);
            var craftString = KspTokenWriter.WriteToken(craftToken, new StringBuilder()).ToString();

            using (var textWriter = new StreamWriter(File.Create(filePath), Encoding.UTF8)) {
                textWriter.Write(craftString);
            }
        }
Exemplo n.º 2
0
        public void ReturnsEmptyObjectForEmptyFile()
        {
            // given
            var textIn = "";

            // when
            var tokenIn   = KspTokenReader.ReadToken(textIn);
            var kspObject = KspObjectReader.ReadObject(tokenIn);
            var tokenOut  = KspObjectWriter.WriteObject(kspObject);
            var textOut   = KspTokenWriter.WriteToken(tokenOut, new StringBuilder()).ToString();

            // then
            Assert.That(textOut, Is.EqualTo(textIn));
        }
Exemplo n.º 3
0
        public void CanReadAndWriteKspObjectsFromSaveFileString()
        {
            // given
            var textIn = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("KSPPartRemover.Tests.Resources.Refuel at Minmus.in.sfs")).ReadToEnd();

            // when
            var tokenIn   = KspTokenReader.ReadToken(textIn);
            var kspObject = KspObjectReader.ReadObject(tokenIn);
            var tokenOut  = KspObjectWriter.WriteObject(kspObject);
            var textOut   = KspTokenWriter.WriteToken(tokenOut, new StringBuilder()).ToString();

            // then
            Assert.That(textOut, Is.EqualTo(textIn));
        }
Exemplo n.º 4
0
        private String KspObjToString(KspObject obj)
        {
            var token = KspObjectWriter.WriteObject(obj);

            return(KspTokenWriter.WriteToken(token, new StringBuilder()).ToString());
        }