Пример #1
0
        public void TestValidation(string ruleName, Vector3 pivot, Vector3 size, float margin, int[] willFailedTargetIndices)
        {
            var rule = new BoothBoundsRule(ruleName, size, margin, pivot);

            var result = rule.Validate(targetContainer);

            if (willFailedTargetIndices.Length == 0)
            {
                Assert.That(result.Issues.Count, Is.Zero);
            }
            else
            {
                Assert.That(result.Issues.Count, Is.GreaterThanOrEqualTo(willFailedTargetIndices.Length));

                var targets = targetContainer.GetAllObjects();

                foreach (var targetIndex in willFailedTargetIndices)
                {
                    var targetObject = targets[targetIndex];
                    var issue        = result.Issues.Find(i => ((Component)i.target).gameObject == targetObject);

                    Assert.That(issue, Is.Not.Null);
                    Assert.That(issue.level, Is.EqualTo(IssueLevel.Error));
                }
            }
        }
Пример #2
0
        public void TestValidationtarget()
        {
            var baseFolderPath = "Assets/VitDeck/Validator/Tests";
            var assetGuids     = new string[] { "testguid" };
            var assetPaths     = new string[] { "testPath", "testPath2" };
            var assetObjects   = new Object[] { };
            var scenes         = new Scene[] { new Scene() };
            var rootObjects    = new GameObject[] { };
            var allObjects     = new GameObject[] { };
            var target         = new ValidationTarget(baseFolderPath,
                                                      assetGuids,
                                                      assetPaths,
                                                      assetObjects,
                                                      scenes,
                                                      rootObjects,
                                                      allObjects);

            Assert.That(target.GetBaseFolderPath(), Is.EqualTo(baseFolderPath));
            Assert.That(target.GetAllAssetGuids(), Is.EqualTo(assetGuids));
            Assert.That(target.GetAllAssetPaths(), Is.EqualTo(assetPaths));
            Assert.That(target.GetAllAssets(), Is.EqualTo(assetObjects));
            Assert.That(target.GetScenes(), Is.EqualTo(scenes));
            Assert.That(target.GetRootObjects(), Is.EqualTo(rootObjects));
            Assert.That(target.GetAllObjects(), Is.EqualTo(allObjects));
        }
Пример #3
0
        public void TestValidationtargetError()
        {
            var target = new ValidationTarget("Assets/VitDeck/Validator/Tests");

            Assert.That(() => target.GetAllAssetGuids(),
                        Throws.Exception.TypeOf <FatalValidationErrorException>()
                        .And.Message.EqualTo("Faild to get asset GUIDs."));
            Assert.That(() => target.GetAllAssetPaths(),
                        Throws.Exception.TypeOf <FatalValidationErrorException>()
                        .And.Message.EqualTo("Faild to get asset Paths."));
            Assert.That(() => target.GetAllAssets(),
                        Throws.Exception.TypeOf <FatalValidationErrorException>()
                        .And.Message.EqualTo("Faild to get asset Objects."));
            Assert.That(() => target.GetScenes(),
                        Throws.Exception.TypeOf <FatalValidationErrorException>()
                        .And.Message.EqualTo("Faild to get scenes."));
            Assert.That(() => target.GetRootObjects(),
                        Throws.Exception.TypeOf <FatalValidationErrorException>()
                        .And.Message.EqualTo("Faild to get root objects."));
            Assert.That(() => target.GetAllObjects(),
                        Throws.Exception.TypeOf <FatalValidationErrorException>()
                        .And.Message.EqualTo("Faild to get all objects."));
        }