Esempio n. 1
0
        public void WeWillOverrideTheMethod()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);
            trans.Translate();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining("public override void LateUpdate"));
        }
Esempio n. 2
0
 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."));
 }
Esempio n. 3
0
 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."));
 }
Esempio n. 4
0
        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"));
        }
Esempio n. 5
0
        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("));
        }
Esempio n. 6
0
        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"));
        }
Esempio n. 7
0
        public void WeWillOverrideTheStartMethod()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.Translate();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining("public override void Start"));
        }
Esempio n. 8
0
        public void WeWillGetTheClassDefinitionAsWritten()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining(testScript.First(s => s.Contains(" class "))));
        }
 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 + ";"));
 }
Esempio n. 10
0
        public void WeWillReplaceExplicitUnityEngineWithFFWDNamespace()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.Translate();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining("PressPlay.FFWD.Vector3"));
            Assert.That(newScript, Is.Not.StringContaining("UnityEngine.Vector3"));
        }
Esempio n. 11
0
        public void WeWillOverrideTheFixedUpdateMEthodEvenWithABrokenSignature()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.Translate();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining("public override void FixedUpdate"));
            Assert.That(newScript, Is.Not.StringContaining("virtual protected public override void"));
        }
Esempio n. 12
0
        public void WeWillRemoveOldUsings()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.Not.StringContaining("UnityEngine;"));
            Assert.That(newScript, Is.Not.StringContaining("SomeSystem;"));
        }
Esempio n. 13
0
        public void ItWillBeReplacedWithUnityObject()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.Translate();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining("UnityObject myObj;"));
            Assert.That(newScript, Is.StringContaining("(UnityObject myObject"));
        }
Esempio n. 14
0
        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."));
        }
Esempio n. 15
0
        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."));
        }
Esempio n. 16
0
        public void WeWillAddANamespaceAfterUsingStatements()
        {
            ScriptTranslator.ScriptNamespace = "TestNamespace";
            ScriptTranslator trans = new ScriptTranslator(testScript);
            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining(ScriptTranslator.ScriptNamespace));
            Assert.That(newScript.IndexOf("using"), Is.LessThan(newScript.IndexOf(ScriptTranslator.ScriptNamespace)));
        }
Esempio n. 17
0
        public void AllCodeInTheClassWillBeRemoved()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);
            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.Not.StringContaining(testScript.First(s => s.Contains("Start()"))));
            Assert.That(newScript, Is.Not.StringContaining(testScript.First(s => s.Contains("Vector3"))));
            Assert.That(newScript, Is.Not.StringContaining(testScript.First(s => s.Contains("Update()"))));
        }
Esempio n. 18
0
        public void AllCodeInTheClassWillBeRemoved()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.Not.StringContaining(testScript.First(s => s.Contains("Start()"))));
            Assert.That(newScript, Is.Not.StringContaining(testScript.First(s => s.Contains("Vector3"))));
            Assert.That(newScript, Is.Not.StringContaining(testScript.First(s => s.Contains("Update()"))));
        }
 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 + ";"));
            }
        }
Esempio n. 21
0
        public void WeCanAddExtraUsings()
        {
            string           myNamespace = "MyNamespace";
            ScriptTranslator trans       = new ScriptTranslator(testScript);

            ScriptTranslator.DefaultUsings.Add(myNamespace);
            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining("using " + myNamespace + ";"));
        }
Esempio n. 22
0
        public void WeWillAddANamespaceAfterUsingStatements()
        {
            ScriptTranslator.ScriptNamespace = "TestNamespace";
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining(ScriptTranslator.ScriptNamespace));
            Assert.That(newScript.IndexOf("using"), Is.LessThan(newScript.IndexOf(ScriptTranslator.ScriptNamespace)));
        }
Esempio n. 23
0
        public void WeWillAddTheDefinedUsings()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);

            trans.CreateStub();
            string newScript = trans.ToString();

            foreach (string u in ScriptTranslator.DefaultUsings)
            {
                Assert.That(newScript, Is.StringContaining("using " + u + ";"));
            }
        }
Esempio n. 24
0
        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"));
        }
Esempio n. 25
0
        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("));
        }
Esempio n. 26
0
        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"));
        }
Esempio n. 27
0
        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;"));
        }
Esempio n. 29
0
 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);
     }
 }
Esempio n. 30
0
 public void WeWillRemoveOldUsings()
 {
     ScriptTranslator trans = new ScriptTranslator(testScript);
     trans.CreateStub();
     string newScript = trans.ToString();
     Assert.That(newScript, Is.Not.StringContaining("UnityEngine;"));
     Assert.That(newScript, Is.Not.StringContaining("SomeSystem;"));
 }
Esempio n. 31
0
        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]"));
        }
Esempio n. 32
0
        public void WeWillGetTheClassDefinitionAsWritten()
        {
            ScriptTranslator trans = new ScriptTranslator(testScript);
            trans.CreateStub();
            string newScript = trans.ToString();

            Assert.That(newScript, Is.StringContaining(testScript.First(s => s.Contains(" class "))));
        }