예제 #1
0
        public void TestCreateTemplateOptions(string displayName, string organization, string expectedDisplayName, string expectedName, string expectedRootNamespace)
        {
            var options = PackageCreator.CreatePackageTemplateOptions(displayName, organization);

            Assert.AreEqual(expectedDisplayName, options.displayName);
            Assert.AreEqual(expectedName, options.name);
            Assert.AreEqual(expectedRootNamespace, options.rootNamespace);
        }
예제 #2
0
        public void TestCreateTemplateOptions_WithExistingDisplayNameAndNamespace()
        {
            var options = PackageCreator.CreatePackageTemplateOptions("Package Creator Tests", "Unity");

            // Package Creator Tests already exists, it should take Package Creator Tests 1
            Assert.AreEqual("Package Creator Tests 1", options.displayName);
            Assert.AreEqual("com.unity.packagecreatortests1", options.name);
            // Unity.Packageutilitytests1 already exists, it should take Unity.PackageCreatorTests2
            Assert.AreEqual("Unity.PackageCreatorTests2", options.rootNamespace);
        }
예제 #3
0
        public IEnumerator TestCreateTemplateOptions_WithExistingPackageName_EndsWithDigits()
        {
            for (var i = 1; i < 10; i++)
            {
                m_FoldersToDelete.Add(CreateTestPackage(i));
            }

            AssetDatabase.Refresh();

            // Wait for asset db refresh
            yield return(null);

            var options = PackageCreator.CreatePackageTemplateOptions("Package Creator Tests", "Unity");

            Assert.AreEqual("Package Creator Tests 10", options.displayName);
            Assert.AreEqual("com.unity.packagecreatortests10", options.name);
            Assert.AreEqual("Unity.PackageCreatorTests10", options.rootNamespace);
        }
예제 #4
0
        public IEnumerator TestCreateTemplateOptions_WithExistingPackageName_EndsWithDigits_NoMoreNumberAvailable_ThrowsArgumentException()
        {
            var field         = typeof(PackageCreator).GetField("s_MaxNameLoop", BindingFlags.Static | BindingFlags.NonPublic);
            var previousValue = field.GetValue(null);

            field.SetValue(null, s_NameLoopReplacement);

            for (var i = 1; i <= s_NameLoopReplacement; i++)
            {
                m_FoldersToDelete.Add(CreateTestPackage(i));
            }

            AssetDatabase.Refresh();

            // Wait for asset db refresh
            yield return(null);

            Assert.Catch <ArgumentException>(() => PackageCreator.CreatePackageTemplateOptions("Package Creator Tests", "Unity"));
            field.SetValue(null, previousValue);
        }