/// <summary> /// Factory method to get a test <see cref="Scenario"/> instance. /// </summary> /// <param name="parent"> /// The parent, which is of type <see cref="TestCase"/>. /// </param> /// <param name="fullyQualifiedName"> /// The fully qualified name. /// </param> /// <returns> /// The <see cref="Scenario"/> instance. /// </returns> public static Scenario GetTestScenario(TestCase parent, string fullyQualifiedName) { if (parent == null) { throw new ArgumentNullException("parent", "The parent test case cannot be null"); } if (string.IsNullOrWhiteSpace(fullyQualifiedName)) { throw new ArgumentException("Test scenario FQDN cannot be null or empty", "fullyQualifiedName"); } var scenario = new Scenario { TestCase = parent, FullyQualifiedName = fullyQualifiedName }; return scenario; }
/// <summary> /// Initializes a new instance of the <see cref="Scenario"/> class. /// </summary> /// <param name="testCase"> /// The test case. /// </param> /// <param name="name"> /// The name. /// </param> internal Scenario(TestCase testCase, string name) { // TODO: Complete member initialization this.TestCase = testCase; this.Name = name; }
/// <summary> /// Updates the test case element in this instance. /// </summary> /// <param name="testCase"> /// The test case. /// </param> private static void UpdateTestCaseElement(TestCase testCase) { if (testCase == null) { throw new ArgumentNullException("testCase", "Cannont save null test case to test result."); } if (testCase.Saved) { return; } XElement testCaseElement = InitTestCase(testCase); UpdateEntityElement(testCase, testCaseElement); testCase.Messages.ForEach(message => UpdateTestEntityMessageElement(message, testCaseElement)); testCase.Scenarios.ForEach(UpdateScenarioElement); testCase.Saved = true; }
/// <summary> /// Sets test case entity. /// </summary> /// <param name="testClass"> /// The test class. /// </param> /// <param name="useDefaultResultFile"> /// A flag indicating whether to use the default result file. /// </param> protected virtual void SetTestCase(TestClass testClass, bool useDefaultResultFile = false) { if (testClass == null) { throw new ArgumentNullException("testClass", "Test class cannot be null."); } TestCase testCase = testClass.GetTestCase(this.TestContext.FullyQualifiedTestCaseName()); testCase.Name = this.TestContext.TestName; CurrentTestCase = testCase; }
/// <summary> /// Initialize the test case. /// </summary> /// <param name="entity"> /// The entity. /// </param> /// <returns> /// The <see cref="XElement"/>. /// </returns> /// <exception cref="NullReferenceException"> /// </exception> private static XElement InitTestCase(TestCase entity) { if (entity.TestClass == null) { throw new ArgumentNullException( "entity", string.Format("Test case [{0}] is not linked with a test class.", entity.Name)); } // Get the parent element from loaded xml result file XElement parent = InitTestClass(entity.TestClass); XElement testCaseElement = GetEntityElement(entity, parent, Constants.TestCaseElement); if (testCaseElement == null) { testCaseElement = ConstructEntityXElement(entity, Constants.TestCaseElement); parent.Add(testCaseElement); } return testCaseElement; }