Example #1
0
        private static string CreateTestPackage(string suffix = "")
        {
            var options = new PackageTemplateOptions()
            {
                name          = $"com.unity.packagecreatortests{suffix}",
                displayName   = $"Package Creator Tests {suffix}".Trim(),
                rootNamespace = $"Unity.PackageCreatorTests{suffix}"
            };

            return(PackageTemplate.CreatePackage(options));
        }
Example #2
0
        public void TestValidationErrorsAreConcatenated()
        {
            var options = new PackageTemplateOptions();

            try
            {
                PackageTemplate.CreatePackage(options);
                Assert.Fail("Expected PackageTemplate.CreatePackage to throw");
            }
            catch (Exception e)
            {
                Assert.AreEqual($"options parameter is invalid:{Environment.NewLine}name is required{Environment.NewLine}displayName is required", e.Message);
            }
        }
Example #3
0
        public void TestParametersAreValidated(string name, string displayName, string rootNamespace, string templateFolder, string expectedMessage)
        {
            var options = new PackageTemplateOptions()
            {
                name           = name,
                displayName    = displayName,
                rootNamespace  = rootNamespace,
                templateFolder = templateFolder
            };

            try
            {
                PackageTemplate.CreatePackage(options);
                Assert.Fail("Expected PackageTemplate.CreatePackage to throw");
            }
            catch (Exception e)
            {
                Assert.AreEqual($"options parameter is invalid:{Environment.NewLine}{expectedMessage}", e.Message);
            }
        }
        public IEnumerator TestCreatePackage()
        {
            var options = new PackageTemplateOptions()
            {
                name          = "com.unity.my-package",
                displayName   = "My Package",
                rootNamespace = "Unity.MyPackage"
            };
            var packageFolder = PackageTemplate.CreatePackage(options);

            AssetDatabase.Refresh();

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

            var myPackage = MockPackageInfo.GetAll().Single(p => p.name == options.name);

            Assert.AreEqual(packageFolder, "Packages/com.unity.my-package");
            Assert.AreEqual("com.unity.my-package", myPackage.name);
            Assert.AreEqual("My Package", myPackage.displayName);
            Assert.AreEqual("0.0.1", myPackage.version);
            Assert.AreEqual(PackageSource.Embedded, myPackage.source);
        }