Пример #1
0
        private static bool InitializeParameterValues([NotNull] TestFactory factory)
        {
            Dictionary <string, TestParameter> parametersByName =
                factory.Parameters.ToDictionary(
                    testParameter => testParameter.Name);

            foreach (TestParameterValue parameterValue in factory.Condition.ParameterValues)
            {
                TestParameter testParameter;
                if (parametersByName.TryGetValue(parameterValue.TestParameterName,
                                                 out testParameter))
                {
                    parameterValue.DataType = testParameter.Type;
                }
            }

            return(true);
        }
Пример #2
0
        public static TestFactory CreateTestFactory([NotNull] QualityCondition qualityCondition)
        {
            Assert.ArgumentNotNull(qualityCondition, nameof(qualityCondition));

            if (qualityCondition.TestDescriptor == null)
            {
                return(null);
            }

            TestFactory factory =
                TestDescriptorUtils.GetTestFactory(qualityCondition.TestDescriptor);

            if (factory != null)
            {
                factory.Condition = qualityCondition;
                InitializeParameterValues(factory);
            }

            return(factory);
        }
        public static void AddParameterValue(QualityCondition qualityCondition,
                                             [NotNull] string parameterName,
                                             [CanBeNull] Dataset value,
                                             string filterExpression  = null,
                                             bool usedAsReferenceData = false)
        {
            Assert.ArgumentNotNullOrEmpty(parameterName, nameof(parameterName));

            TestFactory factory =
                TestFactoryUtils.GetTestFactory(qualityCondition.TestDescriptor);

            TestParameter parameter = Assert.NotNull(factory).GetParameter(parameterName);

            TestParameterTypeUtils.AssertValidDataset(parameter, value);
            var parameterValue = new DatasetTestParameterValue(parameter, value,
                                                               filterExpression,
                                                               usedAsReferenceData);

            parameterValue.DataType = parameter.Type;
            qualityCondition.AddParameterValue(parameterValue);
        }
        private static void AddScalarParameterValue(QualityCondition qualityCondition,
                                                    [NotNull] string parameterName,
                                                    [CanBeNull] object value)
        {
            Assert.ArgumentNotNullOrEmpty(parameterName, nameof(parameterName));

            TestFactory factory =
                TestFactoryUtils.GetTestFactory(qualityCondition.TestDescriptor);

            TestParameter parameter = Assert.NotNull(factory).GetParameter(parameterName);

            if (!parameter.IsConstructorParameter && parameter.Type.IsValueType &&
                (value == null || value as string == string.Empty))
            {
                return;
            }

            var parameterValue = new ScalarTestParameterValue(parameter, value);

            parameterValue.DataType = parameter.Type;
            qualityCondition.AddParameterValue(parameterValue);
        }