public void Ctor_MethodType_IsDefault(DataObjectMethodType methodType, bool isDefault) { var attribute = new DataObjectMethodAttribute(methodType, isDefault); Assert.Equal(methodType, attribute.MethodType); Assert.Equal(isDefault, attribute.IsDefault); }
public void Ctor_MethodType(DataObjectMethodType methodType) { var attribute = new DataObjectMethodAttribute(methodType); Assert.Equal(methodType, attribute.MethodType); Assert.False(attribute.IsDefault); }
public void Equals_Other_ReturnsExpected(DataObjectMethodAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); if (other is DataObjectMethodAttribute) { Assert.Equal(expected, attribute.GetHashCode().Equals(other.GetHashCode())); } }
public void EqualsTest() { DataObjectMethodAttribute a1 = new DataObjectMethodAttribute(DataObjectMethodType.Fill); DataObjectMethodAttribute a2 = new DataObjectMethodAttribute(DataObjectMethodType.Delete); Assert.IsFalse(a1.Equals(a2), "#1"); DataObjectMethodAttribute a3 = new DataObjectMethodAttribute(DataObjectMethodType.Delete); Assert.IsTrue(a2.Equals(a3), "#2"); }
public static IEnumerable <object[]> Match_TestData() { var attribute = new DataObjectMethodAttribute(DataObjectMethodType.Fill, true); yield return(new object[] { attribute, attribute, true }); yield return(new object[] { attribute, new DataObjectMethodAttribute(DataObjectMethodType.Fill, true), true }); yield return(new object[] { attribute, new DataObjectMethodAttribute(DataObjectMethodType.Delete, true), false }); yield return(new object[] { attribute, new DataObjectMethodAttribute(DataObjectMethodType.Fill, false), true }); yield return(new object[] { attribute, new object(), false }); yield return(new object[] { attribute, null, false }); }
private static bool FilterMethodByDataObjectMethodType(MemberInfo methodInfo, object objSearch) { DataObjectMethodAttribute dataObjectMethodAttribute = Attribute.GetCustomAttribute(methodInfo, typeof(DataObjectMethodAttribute)) as DataObjectMethodAttribute; if (dataObjectMethodAttribute == null) { return(false); } MethodTypeAndName typeAndName = (MethodTypeAndName)objSearch; if (String.IsNullOrEmpty(typeAndName.MethodName)) { return((dataObjectMethodAttribute.IsDefault || typeAndName.FirstFoundIsDefault) && (dataObjectMethodAttribute.MethodType == typeAndName.MethodType)); } return(methodInfo.Name.Equals(typeAndName.MethodName, StringComparison.OrdinalIgnoreCase) && (dataObjectMethodAttribute.MethodType == typeAndName.MethodType)); }
public void Match_Other_ReturnsExpected(DataObjectMethodAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Match(other)); }
public void Ctor() { DataObjectMethodAttribute attr = new DataObjectMethodAttribute(DataObjectMethodType.Fill); Assert.IsFalse(attr.IsDefault); }
public void SetMethodInformation(System.Reflection.MethodInfo[] methods, string selectedMethodName, ParameterCollection selectedParameters, DataObjectMethodType methodType, System.Type dataObjectType) { try { this._signatureTextBox.Text = string.Empty; switch (methodType) { case DataObjectMethodType.Select: this._helpLabel.Text = System.Design.SR.GetString("ObjectDataSourceMethodEditor_SelectHelpLabel"); break; case DataObjectMethodType.Update: this._helpLabel.Text = System.Design.SR.GetString("ObjectDataSourceMethodEditor_UpdateHelpLabel"); break; case DataObjectMethodType.Insert: this._helpLabel.Text = System.Design.SR.GetString("ObjectDataSourceMethodEditor_InsertHelpLabel"); break; case DataObjectMethodType.Delete: this._helpLabel.Text = System.Design.SR.GetString("ObjectDataSourceMethodEditor_DeleteHelpLabel"); break; } this._methodComboBox.BeginUpdate(); this._methodComboBox.Items.Clear(); MethodItem item = null; bool flag = false; foreach (System.Reflection.MethodInfo info in methods) { if (this.FilterMethod(info, methodType)) { bool flag2 = false; DataObjectMethodAttribute attribute = Attribute.GetCustomAttribute(info, typeof(DataObjectMethodAttribute), true) as DataObjectMethodAttribute; if ((attribute != null) && (attribute.MethodType == methodType)) { if (!flag) { this._methodComboBox.Items.Clear(); } flag = true; flag2 = true; } else if (!flag) { flag2 = true; } bool flag3 = ObjectDataSourceDesigner.IsMatchingMethod(info, selectedMethodName, selectedParameters, dataObjectType); if (flag2 || flag3) { MethodItem item2 = new MethodItem(info); this._methodComboBox.Items.Add(item2); if (flag3) { item = item2; } else if (((attribute != null) && (attribute.MethodType == methodType)) && (attribute.IsDefault && (selectedMethodName.Length == 0))) { item = item2; } } } } if (methodType != DataObjectMethodType.Select) { this._methodComboBox.Items.Insert(0, new MethodItem(null)); } this._methodComboBox.InvalidateDropDownWidth(); this._methodComboBox.SelectedItem = item; } finally { this._methodComboBox.EndUpdate(); } }