public void CustomisationImportTestImportService() { PrepareTests(); var requests = TestCustomisationImportRequest.GetTestRequests(ExecutionPath); DeleteRelationships(requests); DeleteEntities(requests); DeleteOptionSets(requests); var importService = new XrmCustomisationImportService(XrmRecordService); foreach (var request in requests) { var response = importService.Execute(request, Controller); if (response.HasError) { Assert.Fail(response.GetResponseItemsWithError().First().Exception.DisplayString()); } Assert.IsFalse(response.ExcelReadErrors); Assert.IsNull(response.Exception); ClearCache(); VerifyRelationships(request); VerifyRecordTypes(request); VerifyFields(request); VerifyOptionSets(request); VerifyViews(request); } }
public void CustomisationImportTestSpreadsheetErrors() { var request = new CustomisationImportRequest { ExcelFile = new FileReference("TestCustomisationsSpreadsheetErrors.xlsx"), Entities = true, Fields = true, Relationships = true, Views = true, SharedOptionSets = true, FieldOptionSets = true }; var importService = new XrmCustomisationImportService(XrmRecordService); var response = importService.Execute(request, Controller); Assert.IsTrue(response.ExcelReadErrors); Assert.IsNull(response.Exception); }
public void CustomisationImportTestImportServiceAddToSolution() { //verifies that entities or shared option sets //are added to solution for customisation import where selected PrepareTests(); var testSolution = ReCreateTestSolution(); //initial verifies created entity, field, shared option set and n2n relationship var request = new CustomisationImportRequest { ExcelFile = new FileReference("TestCustomisationsAddToSolution.xlsx"), Entities = true, Fields = true, Relationships = true, Views = false, FieldOptionSets = true, SharedOptionSets = true, AddToSolution = true, Solution = testSolution.ToLookup() }; var importService = new XrmCustomisationImportService(XrmRecordService); var response = importService.Execute(request, CreateServiceRequestController()); if (response.HasError) { Assert.Fail(response.GetResponseItemsWithError().First().Exception.DisplayString()); } Assert.IsFalse(response.ExcelReadErrors); Assert.IsNull(response.Exception); var currentComponentIds = XrmRecordService.RetrieveAllAndClauses(Entities.solutioncomponent, new[] { new Condition(Fields.solutioncomponent_.solutionid, ConditionType.Equal, testSolution.Id) }, null).Select(c => c.GetIdField(Fields.solutioncomponent_.objectid)); var dummyResponse = new CustomisationImportResponse(); var relationShipmetadata = CustomisationImportService.ExtractRelationshipMetadataFromExcel(request.ExcelFile.FileName, Controller, response).Values; var optionMetadata = CustomisationImportService.ExtractOptionSetsFromExcel(request.ExcelFile.FileName, Controller, response) .Where(o => o.IsSharedOptionSet); var fieldMetadata = CustomisationImportService.ExtractFieldMetadataFromExcel(request.ExcelFile.FileName, Controller, optionMetadata, response).Values; var typeMetadata = CustomisationImportService.ExtractRecordMetadataFromExcel(request.ExcelFile.FileName, Controller, fieldMetadata, response).Values; Assert.IsTrue(relationShipmetadata.All(r => currentComponentIds.Contains(XrmRecordService.GetRecordTypeMetadata(r.RecordType1).MetadataId))); Assert.IsTrue(relationShipmetadata.All(r => currentComponentIds.Contains(XrmRecordService.GetRecordTypeMetadata(r.RecordType2).MetadataId))); Assert.IsTrue(optionMetadata.All(r => currentComponentIds.Contains(XrmRecordService.GetSharedPicklist(r.SchemaName).MetadataId))); Assert.IsTrue(fieldMetadata.All(r => currentComponentIds.Contains(XrmRecordService.GetRecordTypeMetadata(r.RecordType).MetadataId))); Assert.IsTrue(typeMetadata.All(r => currentComponentIds.Contains(XrmRecordService.GetRecordTypeMetadata(r.SchemaName).MetadataId))); //this one verifies where just fields picklist options and entity views testSolution = ReCreateTestSolution(); request = new CustomisationImportRequest { ExcelFile = new FileReference("TestCustomisationsAddToSolution.xlsx"), Entities = false, Fields = false, Relationships = false, Views = true, FieldOptionSets = true, SharedOptionSets = true, AddToSolution = true, Solution = testSolution.ToLookup() }; importService = new XrmCustomisationImportService(XrmRecordService); response = importService.Execute(request, CreateServiceRequestController()); if (response.HasError) { Assert.Fail(response.GetResponseItemsWithError().First().Exception.DisplayString()); } Assert.IsFalse(response.ExcelReadErrors); Assert.IsNull(response.Exception); currentComponentIds = XrmRecordService.RetrieveAllAndClauses(Entities.solutioncomponent, new[] { new Condition(Fields.solutioncomponent_.solutionid, ConditionType.Equal, testSolution.Id) }, null).Select(c => c.GetIdField(Fields.solutioncomponent_.objectid)); //addded for field picklist change Assert.IsTrue(currentComponentIds.Contains(XrmRecordService.GetRecordTypeMetadata(Entities.account).MetadataId)); //addded for field change Assert.IsTrue(currentComponentIds.Contains(XrmRecordService.GetRecordTypeMetadata("new_testentitysolutionadd").MetadataId)); }