private void VerifyRelationships(CustomisationImportRequest request) { var response = new CustomisationImportResponse(); var relationShipmetadata = CustomisationImportService.ExtractRelationshipMetadataFromExcel(request.ExcelFile.FileName, Controller, response).Values; foreach (var metadata in relationShipmetadata) { Assert.IsTrue(XrmRecordService.GetManyToManyRelationships(metadata.RecordType1).Any(r => r.SchemaName == metadata.SchemaName)); var relationshipMatch = XrmRecordService .GetManyToManyRelationships(metadata.RecordType1) .Where(r => r.SchemaName == metadata.SchemaName); Assert.IsTrue(relationshipMatch.Any()); var relationship = relationshipMatch.First(); var loadedMetadata = XrmRecordService.GetManyRelationshipMetadata(relationship.SchemaName, relationship.RecordType1); Assert.AreEqual(loadedMetadata.RecordType1DisplayRelated, metadata.RecordType1DisplayRelated); Assert.AreEqual(loadedMetadata.RecordType2DisplayRelated, metadata.RecordType2DisplayRelated); Assert.AreEqual(loadedMetadata.RecordType1UseCustomLabel, metadata.RecordType1UseCustomLabel); Assert.AreEqual(loadedMetadata.RecordType2UseCustomLabel, metadata.RecordType2UseCustomLabel); if (metadata.RecordType1DisplayRelated) { if (metadata.RecordType1UseCustomLabel) { Assert.AreEqual(loadedMetadata.RecordType1CustomLabel, metadata.RecordType1CustomLabel); } else { Assert.AreEqual(loadedMetadata.RecordType1CustomLabel, XrmRecordService.GetCollectionName(metadata.RecordType1)); } Assert.AreEqual(loadedMetadata.RecordType1DisplayOrder, metadata.RecordType1DisplayOrder); } if (metadata.RecordType2DisplayRelated) { if (metadata.RecordType2UseCustomLabel) { Assert.AreEqual(loadedMetadata.RecordType2CustomLabel, metadata.RecordType2CustomLabel); } else { Assert.AreEqual(loadedMetadata.RecordType2CustomLabel, XrmRecordService.GetCollectionName(metadata.RecordType2)); } Assert.AreEqual(loadedMetadata.RecordType2DisplayOrder, metadata.RecordType2DisplayOrder); } } }
private void VerifyRelationships(CustomisationImportRequest request) { var response = new CustomisationImportResponse(); var relationShipmetadata = CustomisationImportService.ExtractRelationshipMetadataFromExcel(request.ExcelFile.FileName, Controller, response).Values; foreach (var metadata in relationShipmetadata) { Assert.IsTrue(XrmRecordService.GetManyToManyRelationships(metadata.RecordType1).Any(r => r.SchemaName == metadata.SchemaName)); var relationshipMatch = XrmRecordService .GetManyToManyRelationships(metadata.RecordType1) .Where(r => r.SchemaName == metadata.SchemaName); Assert.IsTrue(relationshipMatch.Any()); var relationship = relationshipMatch.First(); var loadedMetadata = XrmRecordService.GetManyRelationshipMetadata(relationship.SchemaName, relationship.RecordType1); Assert.AreEqual(loadedMetadata.RecordType1DisplayRelated, metadata.RecordType1DisplayRelated); Assert.AreEqual(loadedMetadata.RecordType2DisplayRelated, metadata.RecordType2DisplayRelated); Assert.AreEqual(loadedMetadata.RecordType1UseCustomLabel, metadata.RecordType1UseCustomLabel); Assert.AreEqual(loadedMetadata.RecordType2UseCustomLabel, metadata.RecordType2UseCustomLabel); //commented out as wasnt populating the custom labels in latest online for unknown reason //if (metadata.RecordType1DisplayRelated) //{ // if (metadata.RecordType1UseCustomLabel) // Assert.AreEqual(loadedMetadata.RecordType1CustomLabel, metadata.RecordType1CustomLabel); // else // Assert.AreEqual(loadedMetadata.RecordType1CustomLabel, XrmRecordService.GetCollectionName(metadata.RecordType1)); // Assert.AreEqual(loadedMetadata.RecordType1DisplayOrder, metadata.RecordType1DisplayOrder); //} //if (metadata.RecordType2DisplayRelated) //{ // if (metadata.RecordType2UseCustomLabel) // Assert.AreEqual(loadedMetadata.RecordType2CustomLabel, metadata.RecordType2CustomLabel); // else // Assert.AreEqual(loadedMetadata.RecordType2CustomLabel, XrmRecordService.GetCollectionName(metadata.RecordType2)); // Assert.AreEqual(loadedMetadata.RecordType2DisplayOrder, metadata.RecordType2DisplayOrder); //} } }