Exemple #1
0
        public static void MissingOutlet_ReturnsErrors()
        {
            OutletScriptableObject obj = ScriptableObject.CreateInstance <OutletScriptableObject>();

            obj.Outlet = null;

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

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
        }
        public static void MissingScriptableObjectInnerOutlet_ReturnsErrors()
        {
            GameObject             gameObject             = new GameObject();
            OutletScriptableObject outletScriptableObject = ScriptableObject.CreateInstance <OutletScriptableObject>();

            outletScriptableObject.Outlet = null;

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

            outletComponent.Outlet = outletScriptableObject;

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

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
        }
Exemple #3
0
        public static void ValidateAllScriptableObjects_EarlyExit_WorksAsExpected()
        {
            OutletScriptableObject objA = ScriptableObject.CreateInstance <OutletScriptableObject>();

            objA.Outlet = null;
            OutletScriptableObject objB = ScriptableObject.CreateInstance <OutletScriptableObject>();

            objB.Outlet = null;
            OutletScriptableObject objC = ScriptableObject.CreateInstance <OutletScriptableObject>();

            objC.Outlet = null;

            var scriptableObjects = new ScriptableObject[] { objA, objB, objC };

            IList <IValidationError> errors = ValidationUtil.ValidateAllScriptableObjects(scriptableObjects, earlyExitOnError: true);

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
        }
        public static void MissingScriptableObjectValidationError_ReturnsExpected()
        {
            GameObject             gameObject             = new GameObject();
            OutletScriptableObject outletScriptableObject = ScriptableObject.CreateInstance <OutletScriptableObject>();

            outletScriptableObject.Outlet = null;

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

            outletComponent.Outlet = outletScriptableObject;

            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(outletScriptableObject.GetLocalId()));
            Assert.That(error.ObjectType, Is.EqualTo(typeof(OutletScriptableObject)));
            Assert.That(error.MemberInfo, Is.EqualTo(typeof(OutletScriptableObject).GetField("Outlet")));
            Assert.That(error.ContextObject, Is.EqualTo(outletScriptableObject));
        }