public static void ValidateAllGameObjectsInScenes_EarlyExit_WorksAsExpected()
        {
            ValidatorIgnoredAssetPathProvider.SetCurrentProvider(() => new ValidatorIgnoredAssetPath[0]);
            Scene scene = EditorSceneManager.OpenScene(GetPathToScene("TestMissingOutletsScene"));
            IList <IValidationError> errors = ValidationUtil.ValidateAllGameObjectsInScenes(new Scene[] { scene }, earlyExitOnError: true);

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
            ValidatorIgnoredAssetPathProvider.ClearCurrentProvider();
        }
Exemple #2
0
 public static void ValidatorTestBrokenPrefabs_All_ReturnErrors()
 {
     ValidatorIgnoredAssetPathProvider.SetCurrentProvider(() => new ValidatorIgnoredAssetPath[0]);
     GameObject[] brokenPrefabs = Resources.LoadAll <GameObject>("DTValidatorTestBrokenPrefabs");
     foreach (GameObject prefab in brokenPrefabs)
     {
         IList <IValidationError> errors = Validator.Validate(prefab);
         Assert.That(errors, Is.Not.Null, string.Format("Prefab named: '{0}' does not return any validation errors!", prefab.name));
     }
     ValidatorIgnoredAssetPathProvider.ClearCurrentProvider();
 }
        public static void RenamedComponentMissingMonoScript_ReturnsErrors()
        {
            ValidatorIgnoredAssetPathProvider.SetCurrentProvider(() => new ValidatorIgnoredAssetPath[0]);
            GameObject renamedComponentPrefab = Resources.Load <GameObject>("DTValidatorTests/TestRenamedComponentPrefab");

            IList <IValidationError> errors = Validator.Validate(renamedComponentPrefab);

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
            ValidatorIgnoredAssetPathProvider.ClearCurrentProvider();
        }
Exemple #4
0
        public static void BrokenMeshFilterPrefab_ReturnsErrors()
        {
            ValidatorIgnoredAssetPathProvider.SetCurrentProvider(() => new ValidatorIgnoredAssetPath[0]);
            GameObject brokenMeshFilterPrefab = Resources.Load <GameObject>("DTValidatorTests/BrokenMeshFilterPrefab");

            IList <IValidationError> errors = Validator.Validate(brokenMeshFilterPrefab, recursive: true);

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
            ValidatorIgnoredAssetPathProvider.ClearCurrentProvider();
        }
Exemple #5
0
        public static void RecursivePrefabWithMissingOutlet_ReturnsErrors()
        {
            ValidatorIgnoredAssetPathProvider.SetCurrentProvider(() => new ValidatorIgnoredAssetPath[0]);
            GameObject gameObject = new GameObject();

            var outletComponent = gameObject.AddComponent <OutletComponent>();

            GameObject missingOutletPrefab = Resources.Load <GameObject>("DTValidatorTests/TestMissingOutletPrefab");

            outletComponent.Outlet = missingOutletPrefab;

            IList <IValidationError> errors = Validator.Validate(gameObject, recursive: true);

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
            ValidatorIgnoredAssetPathProvider.ClearCurrentProvider();
        }
Exemple #6
0
        public static void WhitelistedMissingOutlet_ReturnsNoErrors()
        {
            ValidatorWhitelistedNamespaceProvider.SetCurrentProvider(WhitelistedOutletComponentNamespaceProvider);
            ValidatorIgnoredNamespaceProvider.SetCurrentProvider(() => new ValidatorIgnoredNamespace[0]);
            ValidatorBlacklistedClassProvider.SetCurrentProvider(() => new ValidatorBlacklistedClass[0]);
            ValidatorIgnoredAssetPathProvider.SetCurrentProvider(() => new ValidatorIgnoredAssetPath[0]);

            GameObject gameObject = new GameObject();

            var outletComponent = gameObject.AddComponent <WhitelistedOutletComponent>();

            outletComponent.Outlet = null;

            IList <IValidationError> errors = Validator.Validate(gameObject);

            Assert.That(errors, Is.Not.Null);

            ValidatorWhitelistedNamespaceProvider.ClearCurrentProvider();
            ValidatorIgnoredNamespaceProvider.ClearCurrentProvider();
            ValidatorBlacklistedClassProvider.ClearCurrentProvider();
            ValidatorIgnoredAssetPathProvider.ClearCurrentProvider();
        }
Exemple #7
0
        public static void RecursivePrefabValidationError_ReturnsExpected()
        {
            ValidatorIgnoredAssetPathProvider.SetCurrentProvider(() => new ValidatorIgnoredAssetPath[0]);
            GameObject gameObject = new GameObject();

            var outletComponent = gameObject.AddComponent <OutletComponent>();

            GameObject missingOutletPrefab = Resources.Load <GameObject>("DTValidatorTests/TestMissingOutletPrefab");

            outletComponent.Outlet = missingOutletPrefab;

            IList <IValidationError> errors = Validator.Validate(gameObject, recursive: true);

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));

            IValidationError error = errors[0];

            Assert.That(error.ObjectLocalId, Is.EqualTo(missingOutletPrefab.GetComponentInChildren <TestOutletComponent>().GetLocalId()));
            Assert.That(error.ObjectType, Is.EqualTo(typeof(TestOutletComponent)));
            Assert.That(error.MemberInfo, Is.EqualTo(typeof(TestOutletComponent).GetField("Outlet")));
            Assert.That(error.ContextObject, Is.EqualTo(missingOutletPrefab));
            ValidatorIgnoredAssetPathProvider.ClearCurrentProvider();
        }