예제 #1
0
        public void XrmLookupServiceVerifyDoesNotCrashIfReferencedRecordDeleted()
        {
            //create object referencing a deleted record
            var solution        = ReCreateTestSolution();
            var testEntryObject = new TestXrmObjectEntryClass()
            {
                XrmLookupField = solution.ToLookup()
            };

            XrmRecordService.Delete(solution);

            //verify the form loads and the invalid value is lceared
            var objectEntryViewModel = new ObjectEntryViewModel(null, null, testEntryObject, FakeFormController.CreateForObject(testEntryObject, new FakeApplicationController(), XrmRecordService));

            objectEntryViewModel.LoadFormSections();
            Assert.IsNull(testEntryObject.XrmLookupField);

            //lets just verify the cascade worked if we had not deleted it
            solution        = ReCreateTestSolution();
            testEntryObject = new TestXrmObjectEntryClass()
            {
                XrmLookupField = solution.ToLookup()
            };
            objectEntryViewModel = new ObjectEntryViewModel(null, null, testEntryObject, FakeFormController.CreateForObject(testEntryObject, new FakeApplicationController(), XrmRecordService));
            objectEntryViewModel.LoadFormSections();
            Assert.IsNotNull(testEntryObject.XrmLookupField);
            Assert.IsNotNull(testEntryObject.XrmLookupFieldCascaded);
        }
예제 #2
0
 public void XrmLookupServiceVerifyDoesNotCrashIfConnectionDoesNotWork()
 {
     try
     {
         var solution        = ReCreateTestSolution();
         var testEntryObject = new TestXrmObjectEntryClass()
         {
             XrmLookupField = solution.ToLookup()
         };
         var classSelfMapper = new ClassSelfMapper();
         var newConnection   = classSelfMapper.Map(GetXrmRecordConfiguration());
         newConnection.OrganizationUniqueName = "Foo";
         var newService           = new XrmRecordService(newConnection);
         var objectEntryViewModel = new ObjectEntryViewModel(null, null, testEntryObject, FakeFormController.CreateForObject(testEntryObject, new FakeApplicationController(), newService));
         objectEntryViewModel.LoadFormSections();
         Assert.IsNotNull(testEntryObject.XrmLookupField);
         Assert.IsNotNull(testEntryObject.XrmLookupFieldCascaded);
     }
     catch (FakeUserMessageException)
     {
     }
 }