private bool CheckIfTestFailedAndFireCallbacks(LightTestFixture fixture, Script script) { var shouldFailTest = TestData.ShouldFailTest; if (LightTestFixture.IsSpecialScript(script) && shouldFailTest) { FixtureSpecialScripFailed?.Invoke(fixture, script); } else if (LightTestFixture.IsSpecialScript(script) && !shouldFailTest) { FixtureSpecialScriptSucceded?.Invoke(fixture, script); } else if (shouldFailTest) { TestFailed?.Invoke(fixture, script); } else { TestPassed?.Invoke(fixture, script); } TestData.ShouldFailTest = false; return(shouldFailTest); }
/// <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(); } } } }
public TestFixture NewTestFixture(LightTestFixture lightTestFixture) { var fixture = new TestFixture(AssetManager, CommandFactory, Profiler, Logger); fixture.ApplyLightFixtureValues(lightTestFixture); Add(fixture); return(fixture); }
private void OnTestPassed(LightTestFixture fixture, Script script) { lock (m_TestStatusDictionaryLock) { var tuple = CreateTuple(fixture, script); SetStatus(tuple, TestStatus.Passed); TestStatusUpdated?.Invoke(); } }
private void CheckIfLightTestFixturesAreEqual(LightTestFixture a, LightTestFixture b) { Assert.AreEqual(a.Name, b.Name, "Names missmatched"); Assert.AreEqual(a.Setup.Name, b.Setup.Name, "Setup names missmatched"); Assert.AreEqual(a.OneTimeTeardown.Name, b.OneTimeTeardown.Name, "Teardown names missmatched"); Assert.AreEqual(a.Setup.Commands.Count(), b.Setup.Commands.Count(), "Setup command count missmatched"); Assert.AreEqual(a.OneTimeTeardown.Commands.Count(), b.OneTimeTeardown.Commands.Count(), "teardown command count missmatched"); Assert.AreEqual(a.Tests.Count, b.Tests.Count, "Test count missmatched"); }
private void OnFixtureIsBeingRun(LightTestFixture lightTestFixture) { var fixtureNode = m_Nodes.FirstOrDefault(node => node.TestFixture.Name == lightTestFixture.Name); if (fixtureNode != null) { m_HighlightedNode = fixtureNode; this.BeginInvokeIfCreated(new MethodInvoker(delegate { RefreshTreeListView(); })); } }
private void OnTestIsBeingRun(LightTestFixture lightTestFixture, Script script) { var fixtureNode = m_Nodes.FirstOrDefault(node => node.TestFixture.Name == lightTestFixture.Name); if (fixtureNode != null && fixtureNode.TestFixture != null) { var scriptNode = fixtureNode.Children.FirstOrDefault(node => node.Script?.Name == script.Name); if (scriptNode != null) { m_HighlightedNode = scriptNode; this.BeginInvokeIfCreated(new MethodInvoker(delegate { RefreshTreeListView(); })); } } }
public static LightTestFixture Deserialize(TreeNode <YamlObject> tree) { var root = new TreeNode <LightScript>(); var fixture = new LightTestFixture(); YamlSerializer.DeserializeSimpleProperties(fixture, tree); foreach (var yamlScriptNode in tree) { var s = YamlScriptIO.Deserialize(yamlScriptNode); if (s == null || s.Name == null && s.Commands.Count() == 0) // Test fixture name is also part of the tree, so skip it { continue; } fixture.AddScript(Script.FromLightScript(s)); } return(fixture); }
public static TreeNode <YamlObject> Serialize(LightTestFixture fixture) { var level = 0; var fixtureObject = new YamlObject(level, fixture.GetType().Name, ""); var tree = new TreeNode <YamlObject>(fixtureObject); foreach (var n in YamlSerializer.SerializeSimpleProperties(fixture, level + 1)) { tree.AddChild(n); } tree.Join(YamlScriptIO.Serialize(fixture.Setup.ToLightScript(), level + 1)); tree.Join(YamlScriptIO.Serialize(fixture.TearDown.ToLightScript(), level + 1)); tree.Join(YamlScriptIO.Serialize(fixture.OneTimeSetup.ToLightScript(), level + 1)); tree.Join(YamlScriptIO.Serialize(fixture.OneTimeTeardown.ToLightScript(), level + 1)); foreach (var t in fixture.Tests) { tree.Join(YamlScriptIO.Serialize(t.ToLightScript(), level + 1)); } return(tree); }
private bool IsSpecialScript(Script Script, BaseScriptManager BaseScriptManager) { return(LightTestFixture.IsSpecialScript(Script) || BaseScriptManager is ScriptManager); }
private Tuple <string, string> CreateTuple(LightTestFixture fixture, Script script) { return(new Tuple <string, string>(fixture.Name, script.Name)); }