public void ExpandInFile_FromSelfFile_Passes() { var stackFrame = new StackFrame(true); var traitsSupporter = new TraitsSupporter() { RootDir = Path.GetDirectoryName(stackFrame.GetFileName()), }; var result = traitsSupporter.ExpandInFile("Traits_ExpandInFile_FromSelfFile.cs.txt"); // Indent was included Test target! var correctText = @"//// $SearchFromSelfFile public int ExpandInFileValue { get; set; } //// End $SearchFromSelfFile using System.IO; public class Apple { ////@@ traits $SearchFromSelfFile public int ExpandInFileValue { get; set; } ////-- Finish traits $SearchFromSelfFile } ".Replace("\r\n", "\n"); Assert.AreEqual(correctText, result.Replace("\r\n", "\n")); }
public void Expand_Passes() { var sourceCode = @"using System.IO; public class Apple { ////@@ traits $Traits } "; var traitsText = @"#region $Traits // this comment must keep but not keep prefix spaces. public int TraitsValue { get; set; } #endregion"; var traitsSupporter = new TraitsSupporter() { TraitsTemplates = new Dictionary <string, string>() { { "Traits", traitsText }, } }; var result = traitsSupporter.Expand(sourceCode); // Indent was included Test target! var correctText = @"using System.IO; public class Apple { ////@@ traits $Traits #region $Traits // this comment must keep but not keep prefix spaces. public int TraitsValue { get; set; } #endregion ////-- Finish traits $Traits } ".Replace("\r\n", "\n"); Logger.Log(Logger.Priority.High, () => $"result -- {System.Environment.NewLine}{result}"); Assert.AreEqual(correctText, result.Replace("\r\n", "\n")); }
public void Expand_TemplateInFile_Passes() { var sourceCode = @"using System.IO; public class Apple { ////@@ traits Packages/com.tositeru.hinode/Tests/Editor/Tools/TraitsSupporter/TestTraitsSupporter.cs $TraitsFromFileTest ////@@ traits $FromTraitsTemplatesProp } "; var traitsSupporter = new TraitsSupporter() { TraitsTemplates = new Dictionary <string, string>() { { "FromTraitsTemplatesProp", "public int FromProps { get; set; }" }, }, }; var result = traitsSupporter.Expand(sourceCode); // Indent was included Test target! var correctText = @"using System.IO; public class Apple { ////@@ traits Packages/com.tositeru.hinode/Tests/Editor/Tools/TraitsSupporter/TestTraitsSupporter.cs $TraitsFromFileTest #region $TraitsFromFileTest // this comment must keep but not keep prefix spaces. public int TraitsFromFileValue { get; set; } #endregion ////-- Finish traits Packages/com.tositeru.hinode/Tests/Editor/Tools/TraitsSupporter/TestTraitsSupporter.cs $TraitsFromFileTest ////@@ traits $FromTraitsTemplatesProp public int FromProps { get; set; } ////-- Finish traits $FromTraitsTemplatesProp } ".Replace("\r\n", "\n"); Logger.Log(Logger.Priority.High, () => $"result -- {System.Environment.NewLine}{result}"); Assert.AreEqual(correctText, result.Replace("\r\n", "\n")); }
public void Expand_AlreadyBeExpanded_Passes() { var sourceCode = @"using System.IO; public class Apple { ////@@ traits $Traits text text text apple apple apple ////-- Finish traits $Traits } "; var traitsText = @"public int TraitsValue { get; set; }"; var traitsSupporter = new TraitsSupporter() { TraitsTemplates = new Dictionary <string, string>() { { "Traits", traitsText }, } }; var result = traitsSupporter.Expand(sourceCode); // Indent was included Test target! var correctText = @"using System.IO; public class Apple { ////@@ traits $Traits public int TraitsValue { get; set; } ////-- Finish traits $Traits } ".Replace("\r\n", "\n"); Logger.Log(Logger.Priority.High, () => $"result -- {System.Environment.NewLine}{result}"); Assert.AreEqual(correctText, result.Replace("\r\n", "\n")); }
public void ExpandInFile_Passes() { var stackFrame = new StackFrame(true); UnityEngine.Debug.Log($"test -- {stackFrame.GetFileName()}"); var traitsSupporter = new TraitsSupporter() { RootDir = Path.GetDirectoryName(stackFrame.GetFileName()), }; var result = traitsSupporter.ExpandInFile("Traits_ExpandInFile.cs.txt"); // Indent was included Test target! var correctText = @"using System.IO; public class Apple { ////@@ traits ./TestTraitsSupporter.cs $ExpandInFileTest public int ExpandInFileValue { get; set; } ////-- Finish traits ./TestTraitsSupporter.cs $ExpandInFileTest } ".Replace("\r\n", "\n"); Assert.AreEqual(correctText, result.Replace("\r\n", "\n")); }