Example #1
0
        public static void IgnoredMissingOutlet_ReturnsNoErrors()
        {
            ValidatorIgnoredNamespaceProvider.SetCurrentProvider(IgnoredOutletComponentNamespaceProvider);
            ValidatorWhitelistedNamespaceProvider.SetCurrentProvider(() => new ValidatorWhitelistedNamespace[0]);
            ValidatorBlacklistedClassProvider.SetCurrentProvider(() => new ValidatorBlacklistedClass[0]);

            GameObject gameObject = new GameObject();

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

            outletComponent.Outlet = null;

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

            Assert.That(errors, Is.Null);

            ValidatorIgnoredNamespaceProvider.ClearCurrentProvider();
            ValidatorWhitelistedNamespaceProvider.ClearCurrentProvider();
            ValidatorBlacklistedClassProvider.ClearCurrentProvider();
        }
        public static void WhitelistedMissingOutlet_AndBlacklisted_DefaultsToWhitelisted()
        {
            ValidatorWhitelistedNamespaceProvider.SetCurrentProvider(WhitelistedOutletComponentNamespaceProvider);
            ValidatorIgnoredNamespaceProvider.SetCurrentProvider(() => new ValidatorIgnoredNamespace[0]);
            ValidatorBlacklistedClassProvider.SetCurrentProvider(BlacklistedOutletComponentClassProvider);

            Debug.unityLogger.logEnabled = false;

            GameObject gameObject = new GameObject();

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

            outletComponent.Outlet = null;

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

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

            Debug.unityLogger.logEnabled = true;
            ValidatorWhitelistedNamespaceProvider.ClearCurrentProvider();
            ValidatorIgnoredNamespaceProvider.ClearCurrentProvider();
            ValidatorBlacklistedClassProvider.ClearCurrentProvider();
        }