public void Equals_Other_ReturnsExpected(ToolboxItemAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); if (other is ToolboxItemAttribute) { Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode())); } }
public void Ctor_Type(Type toolboxItemType) { var attribute = new ToolboxItemAttribute(toolboxItemType); Assert.Equal(toolboxItemType.AssemblyQualifiedName, attribute.ToolboxItemTypeName); Assert.Same(toolboxItemType, attribute.ToolboxItemType); Assert.False(attribute.IsDefaultAttribute()); }
public override ItemToolboxNode GetNode (Type t, ToolboxItemAttribute tba, string attributeCategory, string fullPath, MonoDevelop.Core.ClrVersion referencedRuntime) { if (referencedRuntime != MonoDevelop.Core.ClrVersion.Net_1_1 && referencedRuntime != MonoDevelop.Core.ClrVersion.Net_2_0) return null; bool reflectedRuntime1; if (typeof (System.Web.UI.Control).IsAssignableFrom (t)) reflectedRuntime1 = false; else if (CanRuntime1 && SWUControl1.IsAssignableFrom (t)) reflectedRuntime1 = true; else return null; Type toolboxItemType = (tba.ToolboxItemType == null) ? typeof (ToolboxItem) : tba.ToolboxItemType; //FIXME: fix WebControlToolboxItem so that this isn't necessary //right now it's totally broken in mono if (typeof (System.Web.UI.Design.WebControlToolboxItem).IsAssignableFrom (toolboxItemType)) toolboxItemType = typeof (ToolboxItem); //Create the ToolboxItem. The ToolboxItemToolboxNode will destroy it, but need to //be able to extract data from it first. ToolboxItem item = (ToolboxItem) Activator.CreateInstance (toolboxItemType, new object[] {t}); AspNetToolboxNode node = new AspNetToolboxNode (item); //get the default markup for the tag string webText = reflectedRuntime1? GetWebText1 (t) : GetWebText (t); if (!string.IsNullOrEmpty (webText)) node.Text = webText; if (!string.IsNullOrEmpty (attributeCategory)) node.Category = attributeCategory; else if (reflectedRuntime1) node.Category = GuessCategory1 (t); else node.Category = GuessCategory (t); if (!string.IsNullOrEmpty (fullPath)) node.Type.AssemblyLocation = fullPath; //prevent system.web 1.1 from being shown for 2.0 runtime if (CanRuntime1 && webAssem1.FullName == t.Assembly.FullName) { node.ItemFilters.Add (new ToolboxItemFilterAttribute ("ClrVersion.Net_2_0", ToolboxItemFilterType.Prevent)); } //set filters fom supported runtimes if (referencedRuntime == MonoDevelop.Core.ClrVersion.Net_1_1) { node.ItemFilters.Add (new ToolboxItemFilterAttribute ("ClrVersion.Net_1_1", ToolboxItemFilterType.Require)); } else if (referencedRuntime == MonoDevelop.Core.ClrVersion.Net_2_0) { node.ItemFilters.Add (new ToolboxItemFilterAttribute ("ClrVersion.Net_2_0", ToolboxItemFilterType.Require)); } else if (referencedRuntime == MonoDevelop.Core.ClrVersion.Net_4_0) { node.ItemFilters.Add (new ToolboxItemFilterAttribute ("ClrVersion.Net_4_0", ToolboxItemFilterType.Require)); } return node; }
public void None_Get_ReturnsExpected() { ToolboxItemAttribute attribute = ToolboxItemAttribute.None; Assert.Same(attribute, ToolboxItemAttribute.None); Assert.Empty(attribute.ToolboxItemTypeName); Assert.Null(attribute.ToolboxItemType); Assert.False(attribute.IsDefaultAttribute()); }
public void Default_Get_ReturnsExpected() { ToolboxItemAttribute attribute = ToolboxItemAttribute.Default; Assert.Same(attribute, ToolboxItemAttribute.Default); Assert.Equal("System.Drawing.Design.ToolboxItem, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", attribute.ToolboxItemTypeName); AssertExtensions.Throws <ArgumentException>(null, () => attribute.ToolboxItemType); Assert.True(attribute.IsDefaultAttribute()); }
public override bool Equals(object obj) { if (obj == this) { return(true); } ToolboxItemAttribute attribute = obj as ToolboxItemAttribute; return((attribute != null) && (attribute.ToolboxItemTypeName == this.ToolboxItemTypeName)); }
public override bool Equals(object obj) { if (obj == this) { return(true); } ToolboxItemAttribute other = obj as ToolboxItemAttribute; return((other != null) && (other.ToolboxItemTypeName == ToolboxItemTypeName)); }
public override bool Equals(object o) { ToolboxItemAttribute item = o as ToolboxItemAttribute; if (item == null) { return(false); } return(item.ToolboxItemTypeName == ToolboxItemTypeName); }
public void NonDefaultType () { ToolboxItemAttribute attr = new ToolboxItemAttribute (false); Assert.AreEqual (string.Empty, attr.ToolboxItemTypeName, "#1"); Assert.IsNull (attr.ToolboxItemType, "#2"); Assert.AreEqual (false, attr.IsDefaultAttribute (), "#3"); Assert.AreEqual (string.Empty, ToolboxItemAttribute.None.ToolboxItemTypeName, "#4"); Assert.IsNull (ToolboxItemAttribute.None.ToolboxItemType, "#5"); Assert.AreEqual (false, ToolboxItemAttribute.None.IsDefaultAttribute (), "#6"); }
public void DefaultType () { ToolboxItemAttribute attr = new ToolboxItemAttribute (true); Type toolboxItemType = typeof(global::System.Drawing.Design.ToolboxItem); Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, attr.ToolboxItemTypeName, "#1"); Assert.AreEqual (toolboxItemType, attr.ToolboxItemType, "#2"); Assert.AreEqual (true, attr.IsDefaultAttribute (), "#3"); Assert.AreEqual (attr.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4"); Assert.AreEqual (toolboxItemType.AssemblyQualifiedName, ToolboxItemAttribute.Default.ToolboxItemTypeName, "#5"); Assert.AreEqual (toolboxItemType, ToolboxItemAttribute.Default.ToolboxItemType, "#2"); Assert.AreEqual (true, ToolboxItemAttribute.Default.IsDefaultAttribute (), "#3"); Assert.AreEqual (ToolboxItemAttribute.Default.ToolboxItemTypeName.GetHashCode (), attr.GetHashCode (), "#4"); }
public void Ctor_Bool(bool defaultType) { var attribute = new ToolboxItemAttribute(defaultType); if (defaultType) { Assert.Equal("System.Drawing.Design.ToolboxItem, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", attribute.ToolboxItemTypeName); AssertExtensions.Throws <ArgumentException>(null, () => attribute.ToolboxItemType); } else { Assert.Empty(attribute.ToolboxItemTypeName); Assert.Null(attribute.ToolboxItemType); } Assert.Equal(defaultType, attribute.IsDefaultAttribute()); }
public void Ctor_String(string toolboxItemTypeName, bool expectedIsDefault) { var attribute = new ToolboxItemAttribute(toolboxItemTypeName); Assert.Equal(toolboxItemTypeName, attribute.ToolboxItemTypeName); Type expectedType = Type.GetType(toolboxItemTypeName); if (expectedType != null) { Assert.Equal(expectedType, attribute.ToolboxItemType); Assert.Same(attribute.ToolboxItemType, attribute.ToolboxItemType); } else { AssertExtensions.Throws <ArgumentException>(null, () => attribute.ToolboxItemType); } Assert.Equal(expectedIsDefault, attribute.IsDefaultAttribute()); }
public static IEnumerable <object[]> Equals_TestData() { var attribute = new ToolboxItemAttribute("toolboxItemTypeName"); yield return(new object[] { attribute, attribute, true }); yield return(new object[] { attribute, new ToolboxItemAttribute("toolboxItemTypeName"), true }); yield return(new object[] { attribute, new ToolboxItemAttribute("toolboxitemtypename"), false }); yield return(new object[] { attribute, new ToolboxItemAttribute(defaultType: false), false }); yield return(new object[] { new ToolboxItemAttribute(defaultType: false), new ToolboxItemAttribute(defaultType: false), true }); yield return(new object[] { new ToolboxItemAttribute(defaultType: false), new ToolboxItemAttribute("toolboxItemTypeName"), false }); yield return(new object[] { attribute, new object(), false }); yield return(new object[] { attribute, null, false }); }
//TODO: this method is public so that the toolbox service can special-case subclasses of this //to unify them into a single type-walk in a single remote process /// <param name="type">The <see cref="Type"/> of the item for which a node should be created.</param> /// <param name="attribute">The <see cref="ToolboxItemAttribute"/> that was applied to the type.</param> /// <param name="attributeCategory"> The node's category as detected from the <see cref="CategoryAttribute"/>. /// If it's null or empty, the method will need to infer a value.</param> /// <param name="assemblyPath"> If the assembly is a system package, this value will be null. Else, the method will /// need to record the full path in the node.</param> public abstract ItemToolboxNode GetNode ( Type type, ToolboxItemAttribute attribute, string attributeCategory, string assemblyPath, MonoDevelop.Core.ClrVersion referencedRuntime );
public void InvalidItemTypeName () { ToolboxItemAttribute attr = new ToolboxItemAttribute ("typedoesnotexist"); // this next statement should fail Type type = attr.ToolboxItemType; }
/// <param name="obj">The object to compare.</param> public override bool Equals(object o) { ToolboxItemAttribute toolboxItemAttribute = o as ToolboxItemAttribute; return(toolboxItemAttribute != null && toolboxItemAttribute.ToolboxItemTypeName == this.ToolboxItemTypeName); }