Ejemplo n.º 1
0
        /// <summary>
        /// This method constructs new dictionary from all tests in old fixture, then iterates new fixture to find matching scripts
        /// Iterating both fixtures would result in O(n^2). With dictionary, it is only O(2n) with some temp memory allocations.
        /// </summary>
        private void ResetTestStatusForModifiedTests(TestFixture oldFixture, LightTestFixture newFixture)
        {
            // dictionary with count is faster on adding elements. Operation complexity is o(1)
            var newScriptsDict = new Dictionary <string, Script>(oldFixture.Tests.Count);

            foreach (var s in oldFixture.Tests)
            {
                newScriptsDict.Add(s.Name, s);
            }

            var oldScripts = newFixture.Tests;

            for (int i = 0; i < oldScripts.Count; ++i)
            {
                var    oldScript = oldScripts[i];
                Script newScript;
                newScriptsDict.TryGetValue(oldScript.Name, out newScript);

                // if new script is different, mark it's status as None
                if (!oldScript.Similar(newScript) && newScript != null)
                {
                    lock (m_TestStatusDictionaryLock)
                    {
                        var tuple = CreateTuple(oldFixture, newScript);
                        SetStatus(tuple, TestStatus.None);

                        TestStatusUpdated?.Invoke();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void OnTestPassed(LightTestFixture fixture, Script script)
 {
     lock (m_TestStatusDictionaryLock)
     {
         var tuple = CreateTuple(fixture, script);
         SetStatus(tuple, TestStatus.Passed);
         TestStatusUpdated?.Invoke();
     }
 }
Ejemplo n.º 3
0
 private void UpdateTestStatus()
 {
     lock (m_TestStatusDictionaryLock)
     {
         foreach (var fixture in m_TestFixtures)
         {
             foreach (var script in fixture.LoadedScripts)
             {
                 var tuple = CreateTuple(fixture, script);
                 if (!TestStatusDictionary.ContainsKey(tuple))
                 {
                     TestStatusDictionary.Add(tuple, TestStatus.None);
                 }
             }
         }
     }
     TestStatusUpdated?.Invoke();
 }