예제 #1
0
    public void TestResult()
    {
        TestCaseDummy   local  = new TestCaseDummy("TestMethod");
        UUnitTestResult result = local.Run();

        UUnitAssert.Equals("1 run, 0 failed", result.Summary(), "testResult");
    }
예제 #2
0
    public void TestFailure()
    {
        TestCaseDummy   local  = new TestCaseDummy("TestFail");
        UUnitTestResult result = local.Run();

        UUnitAssert.Equals("1 run, 1 failed", result.Summary(), "Failure");
    }
예제 #3
0
 public void Start()
 {
     suite = new UUnitTestSuite ();
     suite.AddAll (typeof(DiagramTest));
     result = suite.Run();
     Debug.Log (result.Summary ());
 }
예제 #4
0
    public void Run(UUnitTestResult testResult)
    {
        setUpStopwatch.Start();
        SetUp();
        setUpStopwatch.Stop();

        testResult.TestStarted();
        bool success = false;
        string message = null;
        try
        {
            Type type = this.GetType();
            MethodInfo method = type.GetMethod(testMethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            eachTestStopwatch.Reset();
            eachTestStopwatch.Start();
            method.Invoke(this, null);
            eachTestStopwatch.Stop();
            success = true;
        }
        catch (TargetInvocationException e)
        {
            message = e.InnerException.ToString();
            success = false;
        }
        finally
        {
            tearDownStopwatch.Start();
            TearDown();
            tearDownStopwatch.Stop();
        }

        testResult.TestComplete(success, eachTestStopwatch.ElapsedMilliseconds, message);
    }
예제 #5
0
    public UUnitTestResult RunAll()
    {
        UUnitTestResult res = new UUnitTestResult();

        foreach (Type t in testCases)
        {
            string typeName = t.Name;
            foreach (MethodInfo m in t.GetMethods())
            {
                if (m.Name.StartsWith("Test") && m.GetParameters().Length == 0)
                {
                    ConstructorInfo[] p = t.GetConstructors();

                    for (int i = 0; i < p.Length; i++)
                    {
                        if (p[i].GetParameters().Length == 0)
                        {
                            DateTime startTime1 = DateTime.Now;
                            DateTime stopTime1  = DateTime.Now;

                            UUnitAssertException ae = null;
                            string errMsg           = null;
                            bool   success          = true;
                            try {
                                UUnitTestCase unitTest = (UUnitTestCase)p[i].Invoke(new object[0]);
                                unitTest.Setup();
                                startTime1 = DateTime.Now;
                                m.Invoke(unitTest, new object[0]);
                                stopTime1 = DateTime.Now;
                                unitTest.TearDown();
                            } catch (System.Reflection.TargetInvocationException e) {
                                stopTime1 = DateTime.Now;
                                ae        = e.InnerException as UUnitAssertException;
                                success   = false;
                                if (ae == null)
                                {
                                    errMsg = e.InnerException.ToString();
                                }
                                else
                                {
                                    errMsg = ae.Message;
                                }
                            } catch (System.Exception ex) {
                                stopTime1 = DateTime.Now;
                                success   = false;
                                errMsg    = ex.ToString();
                            }
                            TimeSpan duration1       = stopTime1 - startTime1;
                            double   timeSpendMillis = duration1.TotalMilliseconds;

                            res.AddTestResult(typeName, m.Name, success, ae, timeSpendMillis, errMsg);
                        }
                    }
                }
            }
        }
        return(res);
    }
예제 #6
0
    public void TestTestSuiteAddAll()
    {
        UUnitTestSuite suite = new UUnitTestSuite();

        suite.AddAll(typeof(TestCaseDummy));
        UUnitTestResult result = suite.Run();

        UUnitAssert.Equals("2 run, 1 failed", result.Summary(), "Suite");
    }
예제 #7
0
        void Start()
        {
            UUnitTestSuite suite = new UUnitTestSuite();

            suite.AddAll(typeof(SpriteAnimationTestCase));
            UUnitTestResult result = suite.Run();

            Debug.Log(result.Summary());
        }
예제 #8
0
    void RunTests()
    {
        UUnitTestSuite testSuite = new UUnitTestSuite();

        testSuite.AddAll(typeof(ScoreControllerTestCase));
        UUnitTestResult result = testSuite.Run();

        Debug.Log(result.Summary());
    }
예제 #9
0
    public void Start()
    {
        UUnitTestSuite suite = new UUnitTestSuite();

        suite.AddAll(typeof(TestCaseTest));
        UUnitTestResult result = suite.Run();

        Debug.Log(result.Summary());
    }
예제 #10
0
    public void TestTestSuiteAdd()
    {
        UUnitTestSuite suite = new UUnitTestSuite();

        suite.Add(new TestCaseDummy("TestMethod"));
        suite.Add(new TestCaseDummy("TestFail"));
        UUnitTestResult result = suite.Run();

        UUnitAssert.Equals("2 run, 1 failed", result.Summary(), "Suite");
    }
예제 #11
0
    private static void RunAllTests()
    {
        ClearDebugLog();

        UUnitTestSuite suite = new UUnitTestSuite();

        FindAndAddAllTestCases(suite);
        UUnitTestResult result = suite.Run();

        Debug.Log(result.Summary());
    }
예제 #12
0
    public UUnitTestResult Run(UUnitTestResult testResult)
    {
        if (testResult == null) {
            testResult = new UUnitTestResult ();
        }

        foreach (UUnitTestCase test in tests) {
            testResult = test.Run (testResult);
        }
        return testResult;
    }
예제 #13
0
    /// <summary>
    /// Initialization
    /// </summary>
    void Start()
    {
        UUnitTestSuite suite = new UUnitTestSuite();

        suite.Add(typeof(PriorityQueueTest));
        suite.Add(typeof(ShortestPathTest));

        UUnitTestResult result = suite.RunAll();

        Debug.Log("Result: " + result.Summary());
    }
예제 #14
0
    public UUnitTestResult Run(UUnitTestResult testResult)
    {
        if (testResult == null)
        {
            testResult = new UUnitTestResult();
        }

        foreach (UUnitTestCase test in tests)
        {
            testResult = test.Run(testResult);
        }
        return(testResult);
    }
	public UUnitTestResult RunAll(){
		UUnitTestResult res = new UUnitTestResult();
		foreach (Type t in testCases){
			string typeName = t.Name;
			foreach (MethodInfo m in t.GetMethods()){
				if (m.Name.StartsWith("Test") && m.GetParameters().Length==0){
					ConstructorInfo[] p = t.GetConstructors();
					
	        		for (int i=0;i<p.Length;i++) {
						if (p[i].GetParameters().Length==0){
							DateTime startTime1 = DateTime.Now; 
							DateTime stopTime1 = DateTime.Now;
							
							UUnitAssertException ae = null;
							string errMsg = null;
							bool success = true;
							try {
								UUnitTestCase unitTest = (UUnitTestCase)p[i].Invoke(new object[0]);	
								unitTest.Setup();
								startTime1 = DateTime.Now;
								m.Invoke(unitTest, new object[0]);
								stopTime1 = DateTime.Now;
								unitTest.TearDown();
							} catch (System.Reflection.TargetInvocationException e){
								stopTime1 = DateTime.Now;
								ae = e.InnerException as UUnitAssertException;
								success = false;
								if (ae==null){
									errMsg = e.InnerException.ToString();
								} else {
									errMsg = ae.Message;
								}
							} catch (System.Exception ex) {
								stopTime1 = DateTime.Now;
								success = false;
								errMsg = ex.ToString();
								
							}
							TimeSpan duration1 = stopTime1 - startTime1;
							double timeSpendMillis = duration1.TotalMilliseconds;
						
							res.AddTestResult(typeName,m.Name,success, ae, timeSpendMillis, errMsg);
						}
	        		}
				}
			}
		}
		return res;
	}
예제 #16
0
    public UUnitTestResult Run(UUnitTestResult testResult)
    {
        if (testResult == null) {
            testResult = new UUnitTestResult ();
        }

        SetUp ();

        testResult.TestStarted ();
        try {
            Type type = this.GetType ();
            MethodInfo method = type.GetMethod (testMethodName);
            method.Invoke (this, null);
        } catch (TargetInvocationException e) {
            testResult.TestFailed ();
            Debug.Log (e.InnerException);
        } finally {
            TearDown ();
        }

        return testResult;
    }
예제 #17
0
    public UUnitTestResult Run(UUnitTestResult testResult)
    {
        if (testResult == null)
        {
            testResult = new UUnitTestResult();
        }

        SetUp();

        testResult.TestStarted();
        try {
            Type       type   = this.GetType();
            MethodInfo method = type.GetMethod(testMethodName);
            method.Invoke(this, null);
        } catch (TargetInvocationException e) {
            testResult.TestFailed();
            Debug.Log(e.InnerException);
        } finally {
            TearDown();
        }

        return(testResult);
    }
예제 #18
0
        static int Main(string[] args)
        {
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "-testInputsFile" && (i + 1) < args.Length)
                {
                    string filename = args[i + 1];
                    if (File.Exists(filename))
                    {
                        string testInputsFile = File.ReadAllText(filename);
                        var    serializer     = JsonSerializer.Create(PlayFabSettings.JsonSettings);
                        var    testInputs     = serializer.Deserialize <Dictionary <string, string> >(new JsonTextReader(new StringReader(testInputsFile)));
                        PlayFabApiTest.SetTitleInfo(testInputs);
                    }
                    else
                    {
                        Console.WriteLine("Loading testSettings file failed: " + filename);
                        Console.WriteLine("From: " + Directory.GetCurrentDirectory());
                    }
                }
            }

            UUnitTestSuite suite = new UUnitTestSuite();

            // With this call, we should only expect the unittests within PlayFabSDK to run - This could be expanded by adding other assemblies manually
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                suite.FindAndAddAllTestCases(assembly, typeof(UUnitTestCase));
            }

            suite.RunAllTests();
            UUnitTestResult result = suite.GetResults();

            Console.WriteLine(result.Summary());
            Console.WriteLine();
            return(result.AllTestsPassed() ? 0 : 1);
        }