public static void EmptyList_ReturnsNoErrors()
        {
            GameObject          gameObject      = new GameObject();
            ListOutletComponent outletComponent = gameObject.AddComponent <ListOutletComponent>();

            outletComponent.Outlets = new List <GameObject>();

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

            Assert.That(errors, Is.Null);
        }
예제 #2
0
        public static void MissingListOfInnerOutlet_ReturnsErrors()
        {
            GameObject          gameObject      = new GameObject();
            ListOutletComponent outletComponent = gameObject.AddComponent <ListOutletComponent>();

            outletComponent.Outlets = new List <Outlet>();
            outletComponent.Outlets.Add(new Outlet());

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

            Assert.That(errors, Is.Not.Null);
        }
        public static void MissingOutletInList_ReturnsErrors()
        {
            GameObject          gameObject      = new GameObject();
            ListOutletComponent outletComponent = gameObject.AddComponent <ListOutletComponent>();

            outletComponent.Outlets = new List <GameObject>();
            outletComponent.Outlets.Add(null);

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

            Assert.That(errors, Is.Not.Null);
            Assert.That(errors.Count, Is.EqualTo(1));
        }
        public static void MissingOutletValidationError_ReturnsExpected()
        {
            GameObject          gameObject      = new GameObject();
            ListOutletComponent outletComponent = gameObject.AddComponent <ListOutletComponent>();

            outletComponent.Outlets = new List <GameObject>();
            outletComponent.Outlets.Add(null);

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

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

            IValidationError error = errors[0];

            Assert.That(error.ObjectLocalId, Is.EqualTo(outletComponent.GetLocalId()));
            Assert.That(error.ObjectType, Is.EqualTo(typeof(ListOutletComponent)));
            Assert.That(error.MemberInfo, Is.EqualTo(typeof(ListOutletComponent).GetField("Outlets")));
            Assert.That(error.ContextObject, Is.EqualTo(gameObject));
        }