static Constants() { TestClassProperty = TestProperty.Register("TestClass", "Test class", typeof(string), TestPropertyAttributes.Hidden, typeof(Constants)); TestMethodProperty = TestProperty.Register("TestMethod", "Test method", typeof(string), TestPropertyAttributes.Hidden, typeof(Constants)); }
public void GetMetadata_Returns_Supplied_Value_For_Unrelated_Class() { var metadata = new PropertyMetadata(); var target = new TestProperty <string>("test", typeof(Class3), metadata); Assert.Same(metadata, target.GetMetadata <Class2>()); }
public void WhenPropertiesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyPropertiesAvailableStatus(includeAllProperties: true); var runtimeModel = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "PropertyName", value: "A"); var cache = IPropertyPageQueryCacheFactory.Create(); var property = new TestProperty { Name = "A", DisplayName = "Page A", Description = "This is the description for Page A", HelpUrl = "https://mypage", Category = "general", DataSource = new DataSource { HasConfigurationCondition = false } }; var result = (UIPropertyValue)UIPropertyDataProducer.CreateUIPropertyValue(runtimeModel, id, cache, property, order: 42, properties); Assert.Equal(expected: "A", actual: result.Name); Assert.Equal(expected: "Page A", actual: result.DisplayName); Assert.Equal(expected: "This is the description for Page A", actual: result.Description); Assert.True(result.ConfigurationIndependent); Assert.Equal(expected: "general", actual: result.CategoryName); Assert.Equal(expected: 42, actual: result.Order); Assert.Equal(expected: "string", actual: result.Type); }
public void GetMetadata_Returns_Supplied_Value() { var metadata = new AvaloniaPropertyMetadata(); var target = new TestProperty <string>("test", typeof(Class1), metadata); Assert.Same(metadata, target.GetMetadata <Class1>()); }
static VsTestFilter() { // Initialize the property cache SupportedPropertiesCache = new Dictionary <string, TestProperty>(StringComparer.OrdinalIgnoreCase) { ["FullyQualifiedName"] = TestCaseProperties.FullyQualifiedName, ["Name"] = TestCaseProperties.DisplayName, ["TestCategory"] = CategoryList.NUnitTestCategoryProperty, ["Category"] = CategoryList.NUnitTestCategoryProperty, }; // Initialize the trait cache var priorityTrait = new NTrait("Priority", ""); var categoryTrait = new NTrait("Category", ""); SupportedTraitCache = new Dictionary <string, NTrait>(StringComparer.OrdinalIgnoreCase) { ["Priority"] = priorityTrait, ["TestCategory"] = categoryTrait, ["Category"] = categoryTrait }; // Initialize the trait property map, since TFS doesnt know about traits TraitPropertyMap = new Dictionary <NTrait, TestProperty>(new NTraitNameComparer()); var priorityProperty = TestProperty.Find("Priority") ?? TestProperty.Register("Priority", "Priority", typeof(string), typeof(TestCase)); TraitPropertyMap[priorityTrait] = priorityProperty; var categoryProperty = TestProperty.Find("TestCategory") ?? TestProperty.Register("TestCategory", "TestCategory", typeof(string), typeof(TestCase)); TraitPropertyMap[categoryTrait] = categoryProperty; // Initialize a merged list of properties and traits to fool TFS Build to think traits is properties SupportedProperties = new List <string>(); SupportedProperties.AddRange(SupportedPropertiesCache.Keys); SupportedProperties.AddRange(SupportedTraitCache.Keys); }
public void CreatingAProperty_WithAttributes_AttributesCanBeQueried() { var property = new TestProperty() .WithAttribute(new AttributeA { A = 1 }) .WithAttribute(new AttributeB { B = 2 }) .WithAttribute(new AttributeC { C = 3 }) .WithAttribute(new AttributeA { A = 4 }); Assert.That(property.HasAttribute <AttributeA>(), Is.True); Assert.That(property.HasAttribute <AttributeB>(), Is.True); Assert.That(property.HasAttribute <AttributeC>(), Is.True); Assert.That(property.HasAttribute <ReadOnlyAttribute>(), Is.False); Assert.That(property.GetAttribute <AttributeA>().A, Is.EqualTo(1)); Assert.That(property.GetAttributes <AttributeA>().Count(), Is.EqualTo(2)); }
private DataGridViewRow addTestPropertyRow(TestProperty testProperty) { int index = m_testPropertiesDataGridView.Rows.Add(); DataGridViewRow row = m_testPropertiesDataGridView.Rows[index]; row.Tag = testProperty; // If TestSystemProperty, need to makes some fields readonly. if (testProperty is TestSystemProperty) { row.Cells[ActiveColumn].ReadOnly = true; row.Cells[NameColumn].ReadOnly = true; row.Cells[TypeColumn].ReadOnly = true; row.Cells[TypeColumn].Value = SystemType; row.Cells[DescriptionColumn].ReadOnly = true; } else { row.Cells[TypeColumn].Value = UserType; } row.Cells[ActiveColumn].Value = testProperty.Active; row.Cells[NameColumn].Value = testProperty.Name; row.Cells[TypeColumn].ReadOnly = true; row.Cells[ValueColumn].ValueType = testProperty.Value.GetType(); row.Cells[ValueColumn].Value = testProperty.Value; row.Cells[DescriptionColumn].Value = testProperty.Description; return(row); }
public void WhenPropertiesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyPropertiesAvailableStatus(includeAllProperties: true); var context = IQueryExecutionContextFactory.Create(); var id = new EntityIdentity(key: "PropertyName", value: "A"); var cache = IProjectStateFactory.Create(); var property = new TestProperty { Name = "A", DisplayName = "Page A", Description = "This is the description for Page A", HelpUrl = "https://mypage", Category = "general", Visible = false, DataSource = new DataSource { HasConfigurationCondition = false } }; InitializeFakeRuleForProperty(property); var result = (UIPropertyValue)UIPropertyDataProducer.CreateUIPropertyValue(context, id, cache, QueryProjectPropertiesContext.ProjectFile, property, order: 42, requestedProperties: properties); Assert.Equal(expected: "A", actual: result.Name); Assert.Equal(expected: "Page A", actual: result.DisplayName); Assert.Equal(expected: "This is the description for Page A", actual: result.Description); Assert.True(result.ConfigurationIndependent); Assert.Equal(expected: "general", actual: result.CategoryName); Assert.False(result.IsVisible); Assert.Equal(expected: 42, actual: result.Order); Assert.Equal(expected: "string", actual: result.Type); }
public ActionResult Index(TestProperty prop) { //データベースからテストケースを取得 prop.testCaseList = new DataBaseIo().ExeReader <TestCase>("select * from test_case_t"); return(View(prop)); }
public void EmProperty_FromString_GoodString_GetExpected(string goodString, int expectedValue) { var testProp = new TestProperty("TestKey"); testProp.FromString(goodString); Assert.AreEqual(expectedValue, testProp.Value); }
public void Constructor_Sets_Properties() { var target = new TestProperty <string>("test", typeof(Class1)); Assert.Equal("test", target.Name); Assert.Equal(typeof(string), target.PropertyType); Assert.Equal(typeof(Class1), target.OwnerType); }
private void VerifyDummyPropertyIsRegistered() { var dummyProperty = TestProperty.Find("DummyProperty"); Assert.IsNotNull(dummyProperty); Assert.AreEqual("DummyPropertyLabel", dummyProperty.Label); Assert.AreEqual("System.String", dummyProperty.ValueType); }
/// <summary> /// Initializes a new instance of the <see cref="DataCollectionTestCaseEventManager"/> class. /// </summary> /// <param name="testRunCache"> /// The test run cache. /// </param> public DataCollectionTestCaseEventManager(ITestRunCache testRunCache) { this.testRunCache = testRunCache; this.testResultDictionary = new Dictionary <Guid, List <TestResult> >(); this.testCaseEndStatusMap = new HashSet <Guid>(); FlushResultTestResultPoperty = TestProperty.Register(id: "allowTestResultFlush", label: "allowTestResultFlush", category: string.Empty, description: string.Empty, valueType: typeof(bool), validateValueCallback: null, attributes: TestPropertyAttributes.None, owner: typeof(TestCase)); }
public override bool IsValid(object value) { if (value == null) { return(true); } return(((string)value).IndexOfAny(TestProperty.ToCharArray()) != -1); }
private void Events_DiscoveredTests(object sender, DiscoveredTestsEventArgs e) { TestCaseInfos = TestCaseInfos.Concat(e.DiscoveredTestCases.Select(testCase => { string name = testCase.DisplayName; string[] categories; try { categories = testCase.GetPropertyValue <string[]>(TestProperty.Find("MSTestDiscoverer.TestCategory"), new string[] { }); } catch { categories = new string[] { }; } string description; try { description = testCase.GetPropertyValue <string>(TestProperty.Find("Description"), String.Empty); } catch { description = String.Empty; } var testcaseToolTipBuilder = new StringBuilder(); testcaseToolTipBuilder.Append(name); if (categories.Length > 0) { testcaseToolTipBuilder.Append(Environment.NewLine + "Category:"); foreach (var category in categories) { testcaseToolTipBuilder.Append(Environment.NewLine + " " + category); } } if (!string.IsNullOrEmpty(description)) { testcaseToolTipBuilder.Append(Environment.NewLine + "Description:"); testcaseToolTipBuilder.Append(Environment.NewLine + " " + description); } return(new TestCaseInfo { Category = categories, Description = description, FullName = testCase.FullyQualifiedName, Name = testCase.DisplayName, ToolTipOnUI = testcaseToolTipBuilder.ToString(), }); })); }
/// <summary> /// Gets parent execution id of test result. /// </summary> /// <param name="testResult"></param> /// <returns>Parent execution id.</returns> public Guid GetParentExecutionId(ObjectModel.TestResult testResult) { TestProperty parentExecutionIdProperty = testResult.Properties.FirstOrDefault( property => property.Id.Equals(Constants.ParentExecutionIdPropertyIdentifier)); return(parentExecutionIdProperty == null ? Guid.Empty : testResult.GetPropertyValue(parentExecutionIdProperty, Guid.Empty)); }
public void EmProperty_ToString_GetExpected() { const string key = "TestKey"; var testProp = new TestProperty(key, 1); string expectedValue = $"{key}:{1};"; Assert.AreEqual(1, testProp.Value); Assert.AreEqual(expectedValue, testProp.ToString()); }
public void TestResultPropertiesShouldGetRegisteredAsPartOfDeserializationV2() { TestProperty.TryUnregister("DummyProperty", out var property); var json = "{\"TestCase\":{\"Id\":\"28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b\",\"FullyQualifiedName\":\"sampleTestClass.sampleTestCase\",\"DisplayName\":\"sampleTestClass.sampleTestCase\",\"ExecutorUri\":\"executor://sampleTestExecutor\",\"Source\":\"sampleTest.dll\",\"CodeFilePath\":null,\"LineNumber\":-1,\"Properties\":[]},\"Attachments\":[],\"Outcome\":1,\"ErrorMessage\":\"sampleError\",\"ErrorStackTrace\":\"sampleStackTrace\",\"DisplayName\":\"sampleTestResult\",\"Messages\":[],\"ComputerName\":\"sampleComputerName\",\"Duration\":\"10675199.02:48:05.4775807\",\"StartTime\":\"2007-03-10T00:00:00+00:00\",\"EndTime\":\"9999-12-31T23:59:59.9999999+00:00\"," + "\"Properties\":[{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"},]}"; var test = Deserialize <TestCase>(json, 2); this.VerifyDummyPropertyIsRegistered(); }
public void GetMetadata_Returns_Overridden_Value() { var metadata = new PropertyMetadata(); var overridden = new PropertyMetadata(); var target = new TestProperty <string>("test", typeof(Class1), metadata); target.OverrideMetadata <Class2>(overridden); Assert.Same(overridden, target.GetMetadata <Class2>()); }
public void Property_Equals_Should_Handle_Null() { var p1 = new TestProperty <string>("p1", typeof(Class1)); Assert.NotNull(p1); Assert.NotNull(p1); Assert.False(p1 == null); Assert.False(null == p1); Assert.False(p1.Equals(null)); Assert.True((AvaloniaProperty)null == (AvaloniaProperty)null); }
public void TestCasePropertiesShouldGetRegisteredAsPartOfDeserializationV2() { TestProperty.TryUnregister("DummyProperty", out var property); var json = "{\"Id\": \"be78d6fc-61b0-4882-9d07-40d796fd96ce\",\"FullyQualifiedName\": \"sampleTestClass.sampleTestCase\",\"DisplayName\": \"sampleTestCase\",\"ExecutorUri\": \"executor://sampleTestExecutor\",\"Source\": \"sampleTest.dll\",\"CodeFilePath\": \"/user/src/testFile.cs\", \"LineNumber\": 999," + "\"Properties\": [{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," + "{ \"Key\": { \"Id\": \"TestObject.Traits\", \"Label\": \"Traits\", \"Category\": \"\", \"Description\": \"\", \"Attributes\": 5, \"ValueType\": \"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"}, \"Value\": [{\"Key\": \"Priority\",\"Value\": \"0\"}, {\"Key\": \"Category\",\"Value\": \"unit\"}]}]}"; var test = Deserialize <TestCase>(json, 2); this.VerifyDummyPropertyIsRegistered(); }
public void TestObjectSetPropertyValueShouldNotConvertIfValueMatchesPropertyDataType() { var property = TestProperty.Register("98", "p1", typeof(bool), typeof(TestObject)); var testobj = new TestableTestObject(); // This should not throw even if the runtime type of boolean where as specified // type is object testobj.SetPropertyValue <object>(property, false); Assert.AreEqual(false, testobj.GetPropertyValue(property)); }
static IEnumerable <KeyValuePair <string, string> > GetTraits(TestCase testCase) { var traitProperty = TestProperty.Find("TestObject.Traits"); if (traitProperty != null) { return(testCase.GetPropertyValue(traitProperty, Enumerable.Empty <KeyValuePair <string, string> >().ToArray())); } return(Enumerable.Empty <KeyValuePair <string, string> >()); }
public void GetPropertiesShouldReturnListOfPropertiesInStore() { TestProperty tp = TestProperty.Register("dummyId", "dummyLabel", typeof(int), typeof(TestObjectTests)); var kvp = new KeyValuePair <TestProperty, object>(tp, 123); testCase.SetPropertyValue(kvp.Key, kvp.Value); var properties = testCase.GetProperties().ToList(); Assert.IsTrue(properties.Contains(kvp)); }
public void SetPropertyValue_Trait_CorrectValidation() { var testCase = TestDataCreator.CreateDummyTestCases("Foo.Bar").Single().ToVsTestCase(); testCase.Traits.Add(new Trait("MyTrait", "value1")); //registers TestProperty objects for trait names // ReSharper disable once ObjectCreationAsStatement new TestCaseFilter(MockRunContext.Object, new HashSet <string> { "MyTrait" }, TestEnvironment.Logger); TestProperty property = TestProperty.Find("MyTrait"); Action action = () => testCase.SetPropertyValue(property, "i"); action.ShouldNotThrow(); action = () => testCase.SetPropertyValue(property, "_i"); action.ShouldNotThrow(); action = () => testCase.SetPropertyValue(property, "äöüÄÖÜß$"); action.ShouldNotThrow(); action = () => testCase.SetPropertyValue(property, "_äöüÄÖÜß$"); action.ShouldNotThrow(); // since we are not at the beginning of the method name action = () => testCase.SetPropertyValue(property, "1"); action.ShouldNotThrow(); action = () => testCase.SetPropertyValue(property, "_1"); action.ShouldNotThrow(); action = () => testCase.SetPropertyValue(property, "_"); action.ShouldNotThrow(); action = () => testCase.SetPropertyValue(property, ""); action.ShouldThrow <ArgumentException>().WithMessage("MyTrait"); action = () => testCase.SetPropertyValue(property, "_("); action.ShouldThrow <ArgumentException>().WithMessage("MyTrait"); action = () => testCase.SetPropertyValue(property, "a("); action.ShouldThrow <ArgumentException>().WithMessage("MyTrait"); action = () => testCase.SetPropertyValue(property, "1("); action.ShouldThrow <ArgumentException>().WithMessage("MyTrait"); action = () => testCase.SetPropertyValue(property, "%"); action.ShouldThrow <ArgumentException>().WithMessage("MyTrait"); action = () => testCase.SetPropertyValue(property, "+"); action.ShouldThrow <ArgumentException>().WithMessage("MyTrait"); }
public void TestPreValidateAProperty() { const string resource = @"<cfg> <things> <add name='one' value='something' /> <add name='two' value='Another' /> </things> </cfg>"; var actual = new TestProperty(resource, new TraceLogger()); Assert.AreEqual(0, actual.Errors().Length); Assert.AreEqual(2, actual.Things.Count); }
public GallioAdapter() { LoaderManager.InitializeAndSetupRuntimeIfNeeded(); testIdProperty = TestProperty.Register("Gallio.TestId", "Test id", typeof(string), typeof(TestCase)); testCaseFactory = new TestCaseFactory(testIdProperty); cachingTestCaseFactory = new CachingTestCaseFactory(testCaseFactory, testIdProperty); testResultFactory = new TestResultFactory(); testExplorer = new TestExplorer(cachingTestCaseFactory); testRunner = new TestRunner(cachingTestCaseFactory, testResultFactory, testIdProperty); }
public void OverrideMetadata_Should_Merge_Values() { var metadata = new PropertyMetadata(BindingMode.TwoWay); var notify = (Action <IAvaloniaObject, bool>)((a, b) => { }); var overridden = new PropertyMetadata(); var target = new TestProperty <string>("test", typeof(Class1), metadata); target.OverrideMetadata <Class2>(overridden); var result = target.GetMetadata <Class2>(); Assert.Equal(BindingMode.TwoWay, result.DefaultBindingMode); }
public void TestCasePropertiesShouldGetRegisteredAsPartOfDeserialization() { TestProperty.TryUnregister("DummyProperty", out var property); var json = "{\"Properties\":[{\"Key\":{\"Id\":\"TestCase.FullyQualifiedName\",\"Label\":\"FullyQualifiedName\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.String\"},\"Value\":\"a.b\"}," + "{\"Key\":{\"Id\":\"TestCase.ExecutorUri\",\"Label\":\"Executor Uri\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":1,\"ValueType\":\"System.Uri\"},\"Value\":\"uri://x\"}," + "{\"Key\":{\"Id\":\"TestCase.Source\",\"Label\":\"Source\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"/tmp/a.b.dll\"}," + "{\"Key\":{\"Id\":\"DummyProperty\",\"Label\":\"DummyPropertyLabel\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":0,\"ValueType\":\"System.String\"},\"Value\":\"dummyString\"}," + "{\"Key\":{\"Id\":\"TestObject.Traits\",\"Label\":\"Traits\",\"Category\":\"\",\"Description\":\"\",\"Attributes\":5,\"ValueType\":\"System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]\"},\"Value\":[{\"Key\":\"t\",\"Value\":\"SDJDDHW>,:&^%//\\\\\\\\\\\\\\\\\"}]}]}"; var test = Deserialize <TestCase>(json); this.VerifyDummyPropertyIsRegistered(); }
private static Common.Models.TestProperty Convert(this TestProperty testProperty, object value) { return(new Common.Models.TestProperty() { Attributes = testProperty.Attributes.Convert(), Category = testProperty.Category, Description = testProperty.Description, Id = testProperty.Id, Label = testProperty.Label, ValueType = value == null ? null : value.GetType().AssemblyQualifiedName, Value = JsonConvert.SerializeObject(value) }); }
public CachingTestCaseFactory(ITestCaseFactory testCaseFactory, TestProperty testIdProperty) { this.testCaseFactory = testCaseFactory; this.testIdProperty = testIdProperty; testCases = new KeyedMemoizer<string, TestCase>(); }
public TestRunner(ITestCaseFactory testCaseFactory, ITestResultFactory testResultFactory, TestProperty testIdProperty) { this.testCaseFactory = testCaseFactory; this.testResultFactory = testResultFactory; this.testIdProperty = testIdProperty; }
public TestCaseFactory(TestProperty testIdProperty) { this.testIdProperty = testIdProperty; }
/// <summary> /// Gets a value for a key in the property file /// </summary> /// <param name="propertyName">Key of the property in the config file</param> /// <returns>the value of the key in the property file</returns> public String GetPropertyByName(TestProperty propertyName) { return System.Configuration.ConfigurationManager.AppSettings[propertyName.ToString()]; }