Пример #1
0
        private bool ProcessDataSourceTests(UnitTestElement test, TestMethodInfo testMethodInfo, ITestContext testContext, List <UnitTestElement> tests)
        {
            var dataRows = PlatformServiceProvider.Instance.TestDataSource.GetData(testMethodInfo, testContext);

            if (dataRows == null || !dataRows.Any())
            {
                return(false);
            }

            try
            {
                int rowIndex = 0;

                foreach (var dataRow in dataRows)
                {
                    // TODO: Test serialization
                    rowIndex++;

                    var displayName    = string.Format(CultureInfo.CurrentCulture, Resource.DataDrivenResultDisplayName, test.DisplayName, rowIndex);
                    var discoveredTest = test.Clone();
                    discoveredTest.DisplayName               = displayName;
                    discoveredTest.TestMethod.DataType       = DynamicDataType.DataSourceAttribute;
                    discoveredTest.TestMethod.SerializedData = DataSerializationHelper.Serialize(new[] { (object)rowIndex });
                    tests.Add(discoveredTest);
                }

                return(true);
            }
            finally
            {
                testContext.SetDataConnection(null);
                testContext.SetDataRow(null);
            }
        }