public void WeWillTranslateItToFFWDRandom() { ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("PressPlay.FFWD.Random")); Assert.That(newScript, Is.Not.StringContaining("PressPlay.FFWD.PressPlay.FFWD.")); }
public void WeWillOverrideTheMethod() { ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("public override void LateUpdate")); }
public void WeWillNotDeleteSymboldBeforeRandom() { ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("(PressPlay.FFWD.Random")); Assert.That(newScript, Is.Not.StringContaining("(Random.")); }
public void WeCanAddExtraUsings() { string myNamespace = "MyNamespace"; ScriptTranslator trans = new ScriptTranslator(testScript); ScriptTranslator.DefaultUsings.Add(myNamespace); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("using " + myNamespace + ";")); }
public void WeCanAlsoRemoveAttributesThatHasParameters() { ScriptTranslator.ReplaceAttributes = new System.Collections.Generic.Dictionary<string, string>() { { "AddComponentMenu", "" } }; ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.Not.StringContaining("[AddComponentMenu")); }
public void IfAnAttributeHasACommentedSectionRemoveTheCommentMarkers() { ScriptTranslator.ReplaceAttributes = new System.Collections.Generic.Dictionary<string, string>() { { "AttributeWithComment", "ConvertedAttribute" } }; ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("[ConvertedAttribute(")); }
public void IfAnAttributeHasACommentedSectionItCanBeRemoved() { ScriptTranslator.ReplaceAttributes = new System.Collections.Generic.Dictionary<string, string>() { { "AttributeWithComment", "" } }; ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.Not.StringContaining("[AttributeWithComment")); }
public void WeWillRemoveUsingsNotSetToBeKept() { ScriptTranslator trans = new ScriptTranslator(testScript); ScriptTranslator.UsingsThatShouldBeKept = new List<string> { "System", "System.Diagnostics" }; trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("System;")); Assert.That(newScript, Is.StringContaining("System.Diagnostics;")); Assert.That(newScript, Is.Not.StringContaining("UnityEngine;")); Assert.That(newScript, Is.Not.StringContaining("SomeSystem;")); }
public void WeWillAddTheDefinedUsings() { ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); foreach (string u in ScriptTranslator.DefaultUsings) { Assert.That(newScript, Is.StringContaining("using " + u + ";")); } }
public void IfAnAttributeHasACommentedSectionItCanBeRemoved() { ScriptTranslator.ReplaceAttributes = new System.Collections.Generic.Dictionary <string, string>() { { "AttributeWithComment", "" } }; ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.Not.StringContaining("[AttributeWithComment")); }
public void WeCanAlsoReplaceAttributesThatHasParameters() { ScriptTranslator.ReplaceAttributes = new System.Collections.Generic.Dictionary <string, string>() { { "AddComponentMenu", "AddMenu" } }; ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.Not.StringContaining("[AddComponentMenu(")); Assert.That(newScript, Is.StringContaining("[AddMenu(")); }
public void WeCanRemoveAnAttribute() { ScriptTranslator.ReplaceAttributes = new System.Collections.Generic.Dictionary <string, string>() { { "HideInInspector", "" } }; ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.Not.StringContaining("[]")); Assert.That(newScript, Is.Not.StringContaining("[HideInInspector]")); }
public void WeWillRemoveUsingsNotSetToBeKept() { ScriptTranslator trans = new ScriptTranslator(testScript); ScriptTranslator.UsingsThatShouldBeKept = new List <string> { "System", "System.Diagnostics" }; trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("System;")); Assert.That(newScript, Is.StringContaining("System.Diagnostics;")); Assert.That(newScript, Is.Not.StringContaining("UnityEngine;")); Assert.That(newScript, Is.Not.StringContaining("SomeSystem;")); }
public void WeCanTranslateTheTestScripts() { foreach (string filename in Directory.GetFiles("TestScripts", "*.cs")) { try { ScriptTranslator trans = new ScriptTranslator(File.ReadAllLines(filename)); trans.Translate(); } catch (Exception ex) { Assert.Fail("Exception while translating " + Path.GetFileNameWithoutExtension(filename) + ": " + ex.Message); } } Assert.Pass("We have translated all scripts"); }
private void TranslateScriptFile(string scriptFile) { try { string scriptText = File.ReadAllText(scriptFile); string[] textLines = scriptText.Split('\n'); PressPlay.FFWD.Exporter.ScriptTranslator trans = new ScriptTranslator(textLines); trans.Translate(); string newText = trans.ToString(); string newPath = scriptFile.Replace(Path.Combine(Application.dataPath, config.unityScriptDir), Path.Combine(xnaBaseDir, config.xnaAssets.ScriptDir)); if (!Directory.Exists(Path.GetDirectoryName(newPath))) { Directory.CreateDirectory(Path.GetDirectoryName(newPath)); } File.WriteAllText(newPath, newText); } catch (Exception ex) { Debug.LogError("Error when converting script " + Path.GetFileName(scriptFile) + ": " + ex.Message); } }
public void WeWillReplaceAttributes() { ScriptTranslator.ReplaceAttributes = new System.Collections.Generic.Dictionary<string, string>() { { "HideInInspector", "InspectorGadget" } }; ScriptTranslator trans = new ScriptTranslator(testScript); trans.Translate(); string newScript = trans.ToString(); Assert.That(newScript, Is.StringContaining("[InspectorGadget]")); Assert.That(newScript, Is.Not.StringContaining("[HideInInspector]")); }