public void EqualsObjectCastTest() { string fieldName = "test-fieldName"; DataField dataField = new DataField(fieldName: fieldName); object obj = new DataField(fieldName: fieldName); Assert.True(dataField.Equals(obj)); }
public void EqualsTest() { string fieldName = "test-fieldName"; DataField fieldName1 = new DataField(fieldName: fieldName); Assert.Equal(fieldName1, fieldName1); Assert.Equal(fieldName1, new DataField(fieldName: fieldName)); Assert.NotEqual(fieldName1, new DataField(fieldName: fieldName + "1")); Assert.False(fieldName1.Equals(null)); }
protected override void OnDataBinding(EventArgs e) { if (!string.IsNullOrEmpty(DataField)) { object obj2 = DataBinder.Eval(Page.GetDataItem(), DataField); if (((obj2 != null) && (obj2 != DBNull.Value)) && !string.IsNullOrEmpty(obj2.ToString())) { base.ImageUrl = (string)obj2; } else { SiteSettings masterSettings = SettingsManager.GetMasterSettings(true); if (DataField.Equals("ThumbnailUrl40")) { base.ImageUrl = masterSettings.DefaultProductThumbnail1; } else if (DataField.Equals("ThumbnailUrl60")) { base.ImageUrl = masterSettings.DefaultProductThumbnail2; } else if (DataField.Equals("ThumbnailUrl100")) { base.ImageUrl = masterSettings.DefaultProductThumbnail3; } else if (DataField.Equals("ThumbnailUrl160")) { base.ImageUrl = masterSettings.DefaultProductThumbnail4; } else if (DataField.Equals("ThumbnailUrl180")) { base.ImageUrl = masterSettings.DefaultProductThumbnail5; } else if (DataField.Equals("ThumbnailUrl220")) { base.ImageUrl = masterSettings.DefaultProductThumbnail6; } else if (DataField.Equals("ThumbnailUrl310")) { base.ImageUrl = masterSettings.DefaultProductThumbnail7; } else { base.ImageUrl = masterSettings.DefaultProductThumbnail8; } } } }
private static void ValidateColumnsAreInSchema(Schema schema, DataColumn[] columns) { DataField[] schemaFields = schema.GetDataFields(); DataField[] passedFields = columns.Select(f => f.Field).ToArray(); if (schemaFields.Length != passedFields.Length) { throw new ArgumentException($"schema has {schemaFields.Length} fields, but only {passedFields.Length} are passed", nameof(schema)); } for (int i = 0; i < schemaFields.Length; i++) { DataField sf = schemaFields[i]; DataField pf = schemaFields[i]; if (!sf.Equals(pf)) { throw new ArgumentException($"expected {sf} at position {i} but found {pf}"); } } }