private void VerifyFields(CustomisationImportRequest request) { var response = new CustomisationImportResponse(); var optionMetadata = CustomisationImportService.ExtractOptionSetsFromExcel(request.ExcelFile.FileName, Controller, response); var fieldMetadata = CustomisationImportService.ExtractFieldMetadataFromExcel(request.ExcelFile.FileName, Controller, optionMetadata, response).Values; foreach (var field in fieldMetadata) { Assert.IsTrue(XrmRecordService.FieldExists(field.SchemaName, field.RecordType)); Assert.IsTrue(XrmRecordService.GetFieldLabel(field.SchemaName, field.RecordType) == field.DisplayName); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).Description == field.Description); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).IsMandatory == field.IsMandatory); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).Audit == field.Audit); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).Searchable == field.Searchable); if (field.FieldType == RecordFieldType.String) { Assert.IsTrue(XrmRecordService.GetMaxLength(field.SchemaName, field.RecordType) == ((StringFieldMetadata)field).MaxLength); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).TextFormat == ((StringFieldMetadata)field).TextFormat); } if (field.FieldType == RecordFieldType.Integer) { Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).MinValue == ((IntegerFieldMetadata)field).MinValue); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).MaxValue == ((IntegerFieldMetadata)field).MaxValue); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).IntegerFormat == ((IntegerFieldMetadata)field).IntegerFormat); } if (field.FieldType == RecordFieldType.Decimal) { Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).MinValue == ((DecimalFieldMetadata)field).MinValue); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).MaxValue == ((DecimalFieldMetadata)field).MaxValue); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).DecimalPrecision == ((DecimalFieldMetadata)field).DecimalPrecision); } if (field.FieldType == RecordFieldType.Date) { Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).IncludeTime == ((DateFieldMetadata)field).IncludeTime); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).DateBehaviour == ((DateFieldMetadata)field).DateBehaviour); } if (field.FieldType == RecordFieldType.Picklist) { var actualOptions = XrmRecordService.GetPicklistKeyValues(field.SchemaName, field.RecordType); var expectedOption = ((PicklistFieldMetadata)field).PicklistOptions; VerifyOptionSetsEqual(actualOptions, expectedOption); Assert.AreEqual(field.IsMultiSelect, XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).IsMultiSelect); } if (field.FieldType == RecordFieldType.Double) { Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).MinValue == ((DoubleFieldMetadata)field).MinValue); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).MaxValue == ((DoubleFieldMetadata)field).MaxValue); Assert.IsTrue(XrmRecordService.GetFieldMetadata(field.SchemaName, field.RecordType).DecimalPrecision == ((DoubleFieldMetadata)field).DecimalPrecision); } } }