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); }
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); }
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); }
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); }