Exemplo n.º 1
0
        /// <summary>
        /// Get test data for the current test script.
        /// </summary>
        /// <typeparam name="T">Generic type of the expected test data to be loaded.</typeparam>
        /// <param name="context"></param>
        /// <returns>Test data instance of the current test script.</returns>
        public static T GetTestData <T>(this TestContext context)
        {
            string testCaseID     = context.Test.Properties["CaseID"].ToString();
            string testScriptName = context.Test.FullName;

            if (_testData == null)
            {
                _testData = new Dictionary <string, object>();
            }
            if (!_testData.Keys.Contains(testCaseID))
            {
                _testData.Add(testCaseID, TestDataRepository.GetTestData <T>(testCaseID, testScriptName));
            }

            return((T)_testData[testCaseID]);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load the test data for the specified test script
        /// </summary>
        /// <param name="testDataType">The specified test data type</param>
        /// <param name="testSuiteType">Type of test suite of the target test scipt</param>
        /// <param name="testCaseID">Test case id of the target test script</param>
        /// <param name="dataIndex">Element index of the test data array, which will be passed to the test script as its parameter.</param>
        public MultipleTestDataAttribute(Type testDataType, Type testSuiteType, string testCaseID, int dataIndex)
        {
            var testData = TestDataRepository.GetTestDataElement(testDataType, testSuiteType, testCaseID, dataIndex);

            ReflectionHelper.SetPrivateFieldValue(this, typeof(TestCaseAttribute), "arguments", testData);
        }