public void Properties_Get_ReturnsExpected(Func <DesignerCategoryAttribute> attributeThunk, string expectedCategory) { DesignerCategoryAttribute attribute = attributeThunk(); Assert.Same(attribute, attributeThunk()); Assert.Equal(expectedCategory, attribute.Category); }
public void Equals_Object_ReturnsExpected(DesignerCategoryAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); if (other is DesignerCategoryAttribute otherAttribute) { Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode())); } }
public void Ctor_String(string category, bool expectedIsDefaultAttribute, string expectedTypeId) { var attribute = new DesignerCategoryAttribute(category); Assert.Equal(category, attribute.Category); Assert.Equal(expectedIsDefaultAttribute, attribute.IsDefaultAttribute()); Assert.Equal(expectedTypeId, attribute.TypeId); }
public void Ctor_Default() { var attribute = new DesignerCategoryAttribute(); Assert.Empty(attribute.Category); Assert.True(attribute.IsDefaultAttribute()); Assert.Equal("System.ComponentModel.DesignerCategoryAttribute", attribute.TypeId); }
public override bool Equals(object obj) { if (obj == this) { return(true); } DesignerCategoryAttribute other = obj as DesignerCategoryAttribute; return(other != null && other.Category == Category); }
// Determine if two instances of this class are equal. public override bool Equals(Object obj) { DesignerCategoryAttribute other = (obj as DesignerCategoryAttribute); if (other != null) { return(category == other.category); } else { return(false); } }
// </Snippet1> // <Snippet2> public static int Main() { // Creates a new form. MyForm myNewForm = new MyForm(); // Gets the attributes for the collection. AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewForm); /* Prints the name of the designer by retrieving the * DesignerCategoryAttribute from the AttributeCollection. */ DesignerCategoryAttribute myAttribute = (DesignerCategoryAttribute)attributes[typeof(DesignerCategoryAttribute)]; Console.WriteLine("The category of the designer for this class is: " + myAttribute.Category); return(0); }
public void SetEditable(EditableData[] DataSet) { Tree.Nodes.Clear(); foreach (EditableData ED in DataSet) { Type EDType = ED.GetType(); DesignerCategoryAttribute Cat = EDType.GetCustomAttribute <DesignerCategoryAttribute>(); DisplayNameAttribute DispName = EDType.GetCustomAttribute <DisplayNameAttribute>() ?? new DisplayNameAttribute(EDType.Name); TreeNode CatNode = FindOrCreateCategory(Cat.Category); CatNode.Tag = null; TreeNode EditNode = CatNode.Nodes.Add(DispName.DisplayName); EditNode.Tag = ED; } Tree.ExpandAll(); }
public static IEnumerable <object[]> Equals_TestData() { var attribute = new DesignerCategoryAttribute("category"); yield return(new object[] { attribute, attribute, true }); yield return(new object[] { attribute, new DesignerCategoryAttribute("category"), true }); yield return(new object[] { attribute, new DesignerCategoryAttribute("category2"), false }); yield return(new object[] { attribute, new DesignerCategoryAttribute(string.Empty), false }); // .NET Framework throws a NullReferenceException. if (!PlatformDetection.IsNetFramework) { yield return(new object[] { attribute, new DesignerCategoryAttribute(null), false }); } // .NET Framework throws a NullReferenceException. if (!PlatformDetection.IsNetFramework) { yield return(new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute(null), true }); yield return(new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute("category"), false }); yield return(new object[] { new DesignerCategoryAttribute(null), new DesignerCategoryAttribute(string.Empty), false }); } yield return(new object[] { new DesignerCategoryAttribute("category"), new object(), false }); yield return(new object[] { new DesignerCategoryAttribute("category"), null, false }); yield return(new object[] { new DesignerCategoryAttribute(null), new object(), false }); yield return(new object[] { new DesignerCategoryAttribute(null), null, false }); }
public void DefaultDesignerCategoryAttribute_GetCategory_ReturnsEmptyString(DesignerCategoryAttribute attribute, string expectedCategory) { Assert.Equal(expectedCategory, attribute.Category); }
public void GetHashCode_NullCategory_ThrowsNullReferenceException() { var attribute = new DesignerCategoryAttribute(null); Assert.Throws <NullReferenceException>(() => attribute.GetHashCode()); }