public static void ApplyTestPropertyOverrides(Hashtable testPropertyOverrides) { foreach (DictionaryEntry testPropertyOverride in testPropertyOverrides) { var property = TestProperties.GetProperty(testPropertyOverride.Key as string); if (property != null) { property.Value = testPropertyOverride.Value; property.Description += " (Test property override)"; } else { property = new TestProperty() { Name = testPropertyOverride.Key as string, Value = testPropertyOverride.Value, Description = "Test property override", Active = true }; TestProperties.AddProperty(property); } } }
public static void AddProperty(TestProperty testProperty) { TestUtils.IsNotNull(testProperty, new ArgumentNullException("TestProperty", "The TestProperty argument cannont be a null value.")); TestUtils.IsFalse(string.IsNullOrEmpty(testProperty.Name), new TestPropertyNameException("The test property name cannot be a null or empty string.")); _testPropertyCollection.Add(testProperty); }
public TestProperty(TestProperty testProperty) { TestUtils.IsNotNull(testProperty, new ArgumentNullException("TestProperty", "The TestProperty argument cannot be a null value.")); Name = testProperty.Name; Description = testProperty.Description; Value = testProperty.Value; Active = testProperty.Active; }
public QTF.TestVerdict TestPropertyCollectionTest(string param1, int count) { try { Setup(); QTF.TestProperty property = new QTF.TestProperty() { Name = "MyNewStringProperty", Description = "This is my new fancy property", Value = "Wing Dang Doodle", Active = true, }; QTF.TestProperties.AddProperty(property); property = new QTF.TestProperty() { Name = "MyNewBooleanProperty", Description = "This is my new fancy property", Value = true, Active = true, }; property = new QTF.TestProperty() { Name = "MyNewIntegerProperty", Description = "This is my new integer property", Value = 99, Active = true, }; QTF.TestProperties.AddProperty(property); QTF.TestProperties.Save(@"C:\TestProjects\Quintity\Quintity.TestFramework\Quintity.TestFramework - Trunk\Quintity.TestFramework.Scratch\TestProperties\Quintity.TestFramework.Scratch.props"); TestMessage = "\r\n" + property.ToString(); TestVerdict = QTF.TestVerdict.Pass; } catch (Exception e) { TestMessage += e.ToString(); TestVerdict = QTF.TestVerdict.Error; } finally { Teardown(); } return(TestVerdict); }
/// <summary> /// Parses out and updates passed test property with new value object and possible description from test override entry. /// An override value, if a string, can contain a new test override description (delimited by '|'). /// </summary> /// <param name="testProperty"></param> /// <param name="testPropertyOverride"></param> private static void parseOverrideValue(TestProperty testProperty, DictionaryEntry testPropertyOverride) { // In case value is not string, some other object. dynamic valueElements = testPropertyOverride.Value; // If it is a string, parse out elements. if (testPropertyOverride.Value is string) { // Cast to string and parse on description delimiter. valueElements = ((string)testPropertyOverride.Value).Split(new char[] { '|' }); // First element is always the string value. testProperty.Value = valueElements[0]; // If second string element, new override description var newDescription = valueElements.Length > 1 ? valueElements[1] : string.Empty; testProperty.Description = $"{newDescription}"; } }
public static bool RemoveProperty(string name) { bool success = false; TestProperty testProperty = GetProperty(name); if (null != testProperty) { if (isTestSystemProperty(testProperty)) { throw new TestSystemPropertyChangeException( string.Format("\"{0}\" is a system property and cannot be removed.", name)); } success = _testPropertyCollection.Remove(testProperty); } return(success); }
public static void SetPropertyValue(string name, object value) { TestProperty testProperty = GetProperty(name); if (null != testProperty) { testProperty.Value = value; } else { AddProperty(new TestProperty(name, value)); } string message; if (!TestUtils.IsSerializable(value, out message)) { TestWarning.Fail("The test property for key \"{0}\" is not serializable.\r\n{1}", name, message); } }
public static object GetPropertyValue(string name, object @default) { object value = null; TestProperty testProperty = GetProperty(name); if (null != testProperty) { value = testProperty.Value; } else { if ([email protected]("86529bef-0704-4f55-9df4-45e299e57f9e")) { value = @default; } else { throw new TestPropertyNotFoundException(string.Format("A test property by the name \"{0}\" was not found.", name)); } } return(value); }
private static bool isTestSystemProperty(TestProperty testProperty) { return(testProperty is TestSystemProperty); }
public QTF.TestVerdict TestPropertyCollectionIOTest() { try { Setup(); QTF.TestPropertyCollection2 properties = new QTF.TestPropertyCollection2(); QTF.TestProperty property = new QTF.TestProperty() { Name = "String property", Description = "This is a string property", Value = "Wing Dang Doodle", Active = true }; properties.Add(property); property = new QTF.TestProperty() { Name = "Boolean property", Description = "This is a boolean property", Value = true, Active = true }; properties.Add(property); property = new QTF.TestProperty() { Name = "Integer property", Description = "This is an integer property", Value = -99, Active = false }; properties.Add(property); property = new QTF.TestProperty() { Name = "Null property", Description = "This is a null property", Value = null, Active = false }; properties.Add(property); //serializeToFile(properties, @"c:\temp\TestProperties.xml", null); //properties = deserializeFromFile(@"c:\temp\TestProperties.xml", null); object value; bool success = TryGetValue(properties, "Null property", out value); success = TryGetValue(properties, "Bogus property", out value); success = TryGetValue(properties, "BooLean property", out value); success = TryGetValue(properties, "Integer property", out value); //string name = "Null property"; //var spud = properties.Where(i => i.Name.ToUpper() == name.ToUpper()).FirstOrDefault(); //if (null != spud) //{ // TestVerdict = QTF.TestVerdict.Pass; // TestMessage = spud.Value.ToString(); //} //else //{ // TestVerdict = QTF.TestVerdict.Fail; // TestMessage = spud.Value.ToString(); //} //TestMessage = "\r\n" + properties.ToString(); } catch (Exception e) { TestMessage += e.ToString(); TestVerdict = QTF.TestVerdict.Error; } finally { Teardown(); } return(TestVerdict); }
public void AddProperty(QTF.TestProperty testProperty) { _testProperties.Add(testProperty); }