コード例 #1
0
    private bool Test_MultiSwapping()
    {
        // Test feature
        if (!Test_SwapComponents())
        {
            TestDebug.LogTestNotStarted("Test_MultiSwapping", "Failed!");
            return(false);
        }

        // Initial setup
        bool passed = true;

        _iconComponent.SetActive(true);
        _textComponent.SetActive(false);

        // Execution
        passed &= Test_SwapComponents();
        passed &= Test_SwapComponents();
        passed &= Test_SwapComponents();

        // Test results
        passed &= !_iconComponent.activeSelf && _textComponent.activeSelf;

        if (!passed)
        {
            TestDebug.LogTestFail("Test_MultiSwapping", "MultiSwapping failed!");
        }
        return(passed);
    }
コード例 #2
0
 protected override bool Inner_Test(string scriptName, string testName)
 {
     if (!IsSafe)
     {
         TestDebug.LogTestFail(testName, scriptName + "." + _name + " is null");
         return(false);
     }
     return(true);
 }
コード例 #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            //TestDebug.TestEnumberAllPermutations,false);
            //TestDebug.TestSumEfficiecy(7,1000000,false);
            TestDebug.TestSubstitutionEfficiency(7, 1000000, false);

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
コード例 #4
0
    static void testHeapSort()
    {
        // test HeapSort;
        resetNumber();
        //  开始监视代码运行时间;
        Stopwatch stopwatch = new Stopwatch();

        stopwatch.Start();
        HeapSort.Sort(mNumbers, mNumbers.Count);
        stopwatch.Stop();
        Console.WriteLine("test HeapSort=> {0}毫秒", stopwatch.Elapsed.TotalMilliseconds);
        TestDebug.log(mNumbers);
    }
コード例 #5
0
        public bool Test_All()
        {
            bool passed = true;

            passed &= Test_Fields();
            passed &= Test_Methods();

            if (passed)
            {
                TestDebug.LogTestSucceed("ALL Tests");
            }
            return(passed);
        }
コード例 #6
0
 protected override bool Inner_Test(string scriptName, string testName)
 {
     if (_testMethod == null)
     {
         TestDebug.LogTestFail(testName, scriptName + "." + _name + " is null");
         return(false);
     }
     if (!_testMethod())
     {
         TestDebug.LogTestFail(testName, scriptName + "." + _name + " didn't passed Test()");
         return(false);
     }
     return(true);
 }
コード例 #7
0
        public bool Test()
        {
            string scriptName = _testUtils != null ? _testUtils.ScriptName : TestUtils.kDefaultScriptName;
            string testName   = _testUtils != null ? _testUtils.TestName : TestUtils.kDefaultTestName;

            try
            {
                return(Inner_Test(scriptName, testName));
            }
            catch
            {
                TestDebug.LogTestFail(testName, scriptName + "." + _name + " didn't passed Test(). UNHANDLED ERROR!");
                return(false);
            }
        }
コード例 #8
0
        /// <summary>
        /// Get the methods that will be tested during TestMethods()
        /// </summary>
        private List <BaseTestClass> Test_GetMethods(TestUtils testUtils)
        {
            MonoBehaviour[] scriptComponents = GetComponents <MonoBehaviour>();

            List <BaseTestClass> testMethods = new List <BaseTestClass>();

            foreach (MonoBehaviour mono in scriptComponents)
            {
                var methods = mono.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                foreach (var method in methods)
                {
                    var attributes = method.GetCustomAttributes(typeof(TestingMethodAttribute), true);
                    if (attributes.Length > 0)
                    {
                        ActionTestMethod testMethod = null;

                        // Try use alternative method name
                        var attribute = attributes[0] as TestingMethodAttribute;
                        if (!string.IsNullOrEmpty(attribute.AltMethodName))
                        {
                            var altMethod = Array.Find(methods, x => x.Name == attribute.AltMethodName);
                            if (altMethod != null)
                            {
                                testMethod = new ActionTestMethod(testUtils, altMethod.Name, () => altMethod.Invoke(mono, null));
                            }
                            else
                            {
                                TestDebug.LogTestFail(TestUtils.kTestMethodName, "Alternative name not found for method: " + method.Name);
                            }
                        }

                        // If needed, use method name
                        if (testMethod == null)
                        {
                            testMethod = new ActionTestMethod(testUtils, method.Name, () => method.Invoke(mono, null));
                        }
                        testMethods.Add(testMethod);
                    }
                }
            }
            return(testMethods);
        }
コード例 #9
0
        public bool Test_Fields()
        {
            _testName = kTestFieldsName;
            if (_fieldsList == null)
            {
                TestDebug.LogTestNotStarted(_testName, "Fields list is null");
                return(true);
            }

            bool passed = true;

            foreach (var field in _fieldsList)
            {
                passed &= field.Test();
            }

            if (passed)
            {
                TestDebug.LogTestSucceed(_testName);
            }
            return(passed);
        }
コード例 #10
0
        public bool Test_Methods()
        {
            _testName = kTestMethodName;
            if (_methodsList == null)
            {
                TestDebug.LogTestNotStarted(_testName, "Methods list is null");
                return(true);
            }

            bool passed = true;

            foreach (var method in _methodsList)
            {
                passed &= method.Test();
            }

            if (passed)
            {
                TestDebug.LogTestSucceed(_testName);
            }
            return(passed);
        }
コード例 #11
0
    static void Main(string[] args)
    {
        mNumbers = new List <int>();

        // origin number;
        resetNumber();
        Console.WriteLine("origin number=> ");
        TestDebug.log(mNumbers);

        // test Bubble;
        testBubble();
        // test InsertSort;
        testInsertSort();
        // test QuickSort;
        testQuickSort();
        // test HeapSort;
        testHeapSort();
        // test MergeSort;
        testMergeSort();


        Console.ReadLine();
    }