コード例 #1
0
ファイル: ElementTestUtil.cs プロジェクト: veboys/UIForia
        public static void AssertHierarchyFlags(UIElement element, TypeAssert assertRoot, int depth = 0)
        {
            Assert.AreEqual(element.GetType(), assertRoot.parentType);

            switch (assertRoot.flags)
            {
            case TestEnableFlags.Disabled:
                Assert.IsTrue(element.isDisabled);
                Assert.IsFalse(element.isEnabled);
                break;

            case TestEnableFlags.DisabledSelf:
                Assert.IsTrue(element.isSelfDisabled);
                Assert.IsFalse(element.isSelfEnabled);
                break;

            case TestEnableFlags.DisabledAncestor:
                Assert.IsTrue(element.isDisabled);
                Assert.IsTrue(element.isSelfEnabled);
                Assert.IsFalse(element.isEnabled);
                break;

            case TestEnableFlags.Enabled:
                Assert.IsTrue(element.isEnabled);
                Assert.IsTrue(element.isSelfEnabled);
                Assert.IsFalse(element.isSelfDisabled);
                break;

            case TestEnableFlags.EnabledAncestor:
                break;

            case TestEnableFlags.EnabledSelf:
                Assert.IsTrue(element.isSelfEnabled);
                break;
            }

            if (element.children.Count != assertRoot.childTypes.Length)
            {
                Assert.Fail("Child Count did not match at depth: " + depth);
            }

            for (int i = 0; i < element.children.Count; i++)
            {
                if (element.children[i].GetType() != assertRoot.childTypes[i].parentType)
                {
                    Assert.Fail("Types did not match for child number " + i + " at depth " + depth);
                }

                AssertHierarchy(element.children[i], assertRoot.childTypes[i], depth + 1);
            }
        }
コード例 #2
0
ファイル: ExceptionAssert.cs プロジェクト: hfz-r/mynews-sms
        /// <summary>
        /// Executes a method and asserts that the specified exception is thrown.
        /// </summary>
        /// <typeparam name="T">The type of exception to expect.</typeparam>
        /// <param name="method">The method to execute.</param>
        /// <returns>The thrown exception.</returns>
        public static void InnerException <T>(ExceptionDelegate method)  where T : Exception
        {
            try
            {
                method.Invoke();
            }
            catch (Exception ex)
            {
                TypeAssert.AreEqual(typeof(T), ex.InnerException);

                return;
            }
            Assert.Fail("Expected exception '" + typeof(T).FullName + "' wasn't thrown.");
        }
コード例 #3
0
ファイル: ElementTestUtil.cs プロジェクト: veboys/UIForia
        public static void AssertHierarchy(UIElement element, TypeAssert assertRoot, int depth = 0)
        {
            Assert.AreEqual(element.GetType(), assertRoot.parentType);
            if (element.children.Count != assertRoot.childTypes.Length)
            {
                Assert.Fail("Child Count did not match at depth: " + depth);
            }

            for (int i = 0; i < element.children.Count; i++)
            {
                if (element.children[i].GetType() != assertRoot.childTypes[i].parentType)
                {
                    Assert.Fail($"Types did not match for child number {i} at depth {depth}. {element.children[i].GetType()} is not {assertRoot.childTypes[i].parentType}");
                }

                AssertHierarchy(element.children[i], assertRoot.childTypes[i], depth + 1);
            }
        }