public void Integration_MirrorVariationToPermit_RemoveLocations_Success()
        {
            int startSites          = 5;
            int startDetailsPerSite = 2;


            Guid permitId = _dataAccessIntegrationTestSupport.CreateApplicationAndPermit(OrganizationService, startSites, startDetailsPerSite);

            // 1. Create Application
            Entity variationApplication = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService, ApplicationTypes.Variation, permitId);

            // 2. Call MirrorApplicationSitesToPermit
            //DataAccessApplication.MirrorPermitLocationsAndDetailsToApplication(OrganizationService, variationApplication.Id);

            // 3. Remove 1 location from Application
            Entity[] applicationLocationAndDetails = DataAccessApplication.GetLocationAndLocationDetails(OrganizationService, variationApplication.Id, null);

            _dataAccessIntegrationTestSupport.DeactivateLocation(OrganizationService, applicationLocationAndDetails[0]);

            // 4. Call MirrorApplicationSitesToPermit
            DataAccessApplication.MirrorApplicationLocationsAndDetailsToPermit(OrganizationService, variationApplication.Id);

            // 5. Check the Permit now has had a location removed
            Entity[] permitLocationAndDetails = DataAccessApplication.GetLocationAndLocationDetails(OrganizationService, null, permitId);
            Assert.IsTrue(permitLocationAndDetails.Length == startSites * startDetailsPerSite - startDetailsPerSite);
        }
        public void Integration_MirrorVariationToPermit_AddLocations_Success()
        {
            int startSites          = 2;
            int startDetailsPerSite = 6;
            int additionalSites     = 3;
            int additionalDetails   = 2;

            Guid permitId = _dataAccessIntegrationTestSupport.CreateApplicationAndPermit(OrganizationService, startSites, startDetailsPerSite);

            // 1. Create Application
            Entity variationApplication = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService, ApplicationTypes.Variation, permitId);

            // 2. Call MirrorApplicationSitesToPermit
            DataAccessApplication.MirrorPermitLocationsAndDetailsToApplication(OrganizationService, variationApplication.Id);

            // 3. Add locations to Application

            for (int countSites = 0; countSites < additionalSites; countSites++)
            {
                _dataAccessIntegrationTestSupport.CreateApplicationLocationAndDetails(OrganizationService, variationApplication.Id, "Additional Location " + countSites, additionalDetails, countSites > 1 ? true : false);
            }

            // 6. Call MirrorApplicationSitesToPermit
            DataAccessApplication.MirrorApplicationLocationsAndDetailsToPermit(OrganizationService, variationApplication.Id);


            // 4. Check the Permit now has all the original locations + the new ones
            Entity[] permitLocationAndDetails = DataAccessApplication.GetLocationAndLocationDetails(OrganizationService, null, permitId);
            Assert.IsTrue(permitLocationAndDetails.Length == startSites * startDetailsPerSite + additionalSites * additionalDetails);
        }
        public void Integration_CreateNoteAndFileSeparatelyThenUploadToSharePoint_Success()
        {
            var service     = OrganizationService;
            var application = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService, Model.Crm.ApplicationTypes.NewApplication);
            var notes       = new EntityCollection();

            for (int i = 1; i < 50; i++)
            {
                // Create Annotation
                var annotationEntity = new Entity(Annotation.EntityLogicalName)
                {
                    [Annotation.Fields.ObjectId] = new EntityReference(defra_application.EntityLogicalName, application.Id),
                    [Annotation.Fields.Subject]  = string.Format("File {0} for integration test at {1}", i.ToString(), DateTime.Now)
                };
                annotationEntity[Annotation.Fields.Id] = service.Create(annotationEntity);
                notes.Entities.Add(annotationEntity);
            }

            var cnt = 1;

            foreach (var note in notes.Entities)
            {
                note[Annotation.Fields.FileName]     = string.Format("File{0}.txt", cnt.ToString());
                note[Annotation.Fields.DocumentBody] = "Test Document for integration test".Base64Encode();
                service.Update(note);
                cnt++;
            }

            // Assert ???
        }
Пример #4
0
        public void Integration_RefreshApplicationAnswers_Success()
        {
            Entity application = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService);

            DataAccessApplicationAnswers dal = new DataAccessApplicationAnswers(OrganizationService, new MockTracingService());

            dal.RefreshApplicationAnswers(application.Id);
        }
Пример #5
0
        public void Integration_GetApplicationAnswers_Success()
        {
            Entity application = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService);

            DataAccessApplicationAnswers dal = new DataAccessApplicationAnswers(OrganizationService, new MockTracingService());

            var result = dal.GetApplicationAnswers(application.Id);

            Assert.IsTrue(result == null);
        }
Пример #6
0
        public void Integration_GrantAccessSuccess()
        {
            Entity application = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService);
            List <EntityReference> principals    = new List <EntityReference>();
            EntityReference        teamReference = new EntityReference(Team.EntityLogicalName, new Guid("1d038e0f-47c2-e711-80eb-3863bb357ff8"));

            principals.Add(teamReference);


            OrganizationService.GrantAccess(application.ToEntityReference(), principals, true, true, true, true, true, true, true);

            Assert.IsTrue(true);
        }
        public void Integration_MirrorPermitToVariation_Success()
        {
            // 1. Create application and permit
            Guid permitId = _dataAccessIntegrationTestSupport.CreateApplicationAndPermit(OrganizationService, 2, 5);

            // 2. Create Variation
            Entity variationApplication = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService, ApplicationTypes.Variation, permitId);

            // 3. Call MirrorApplicationSitesToPermit
            //DataAccessApplication.MirrorPermitLocationsAndDetailsToApplication(OrganizationService, variationApplication.Id);

            // 4. Check the Application now has all the Permit locations
            Entity[] applicationLocationAndDetails = DataAccessApplication.GetLocationAndLocationDetails(OrganizationService, variationApplication.Id, null);
            Assert.IsTrue(applicationLocationAndDetails.Length == 10);
        }
        public void Integration_MirrorVariationToPermit_2Locations_NoLocationChanges_Success()
        {
            int startSites          = 2;
            int startDetailsPerSite = 1;

            Guid permitId = _dataAccessIntegrationTestSupport.CreateApplicationAndPermit(OrganizationService, startSites, startDetailsPerSite);

            // 1. Create Application
            Entity variationApplication = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService, ApplicationTypes.Variation, permitId);

            // 6. Call MirrorApplicationSitesToPermit
            DataAccessApplication.MirrorApplicationLocationsAndDetailsToPermit(OrganizationService, variationApplication.Id);

            // 4. Check the Permit now has all the original locations + the new ones
            Entity[] permitLocationAndDetails = DataAccessApplication.GetLocationAndLocationDetails(OrganizationService, null, permitId);
            Assert.IsTrue(permitLocationAndDetails.Length == startSites * startDetailsPerSite);
        }
        public void Integration_CreateNoteAndFileTogetherAndUploadToSharePoint_Success()
        {
            var service     = OrganizationService;
            var application = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService, Model.Crm.ApplicationTypes.NewApplication);

            for (int i = 1; i < 50; i++)
            {
                // Create Annotation
                var annotationEntity = new Entity(Annotation.EntityLogicalName)
                {
                    [Annotation.Fields.ObjectId]     = new EntityReference(defra_application.EntityLogicalName, application.Id),
                    [Annotation.Fields.Subject]      = "Integration Test " + DateTime.Now,
                    [Annotation.Fields.FileName]     = string.Format("File{0}.txt", i.ToString()),
                    [Annotation.Fields.DocumentBody] = "Test Document for integration test".Base64Encode()
                };
                service.Create(annotationEntity);
            }

            // Assert ???
        }
Пример #10
0
        public void Integration_TestSetApplicationAnswerSuccess()
        {
            Entity application = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService);

            DataAccessApplicationAnswers dal = new DataAccessApplicationAnswers(OrganizationService, new MockTracingService());

            // Create
            Guid answedId1 = dal.SetApplicationAnswer("test-question-1", "answer-1", "", application.ToEntityReference(), null, true);

            // Update
            Guid answedId2 = dal.SetApplicationAnswer("test-question-1", "answer-2", "", application.ToEntityReference(), null, true);

            // Create
            Guid answedId3 = dal.SetApplicationAnswer("test-question-2", "answer-3", "", application.ToEntityReference(), null, true);

            // Update
            Guid answedId4 = dal.SetApplicationAnswer("test-question-2", "answer-4", "Answer Text", application.ToEntityReference(), null, true);

            Assert.IsTrue(answedId1 != Guid.Empty);
            Assert.IsTrue(answedId2 != Guid.Empty);
            Assert.IsTrue(answedId3 != Guid.Empty);
            Assert.IsTrue(answedId4 != Guid.Empty);
        }
        public void Integration_GetCountForApplicationsLinkedToPermit_TestTwoActiveApplication_Success()
        {
            // 1. Create Application
            Entity newApplication = DataAccessIntegrationTestSupport.CreateApplication(OrganizationService);

            // 2. Create Application Locations
            for (int count = 0; count < 3; count++)
            {
                _dataAccessIntegrationTestSupport.CreateApplicationLocationAndDetails(OrganizationService, newApplication.Id, "Main Location " + count, 2, count > 1 ? true : false);
            }

            // 3. Create Permit
            Entity application = OrganizationService.Retrieve(Application.EntityLogicalName, newApplication.Id,
                                                              new ColumnSet(Application.PermitNumber));
            string permitNumber = application[Application.PermitNumber].ToString();

            Guid permitId = _dataAccessIntegrationTestSupport.CreatePermit(OrganizationService, permitNumber);

            // 4. Update Application Permit Lookup field
            _dataAccessIntegrationTestSupport.UpdateApplicationPermitLookup(OrganizationService, newApplication, permitId);

            // 5. Call MirrorApplicationSitesToPermit
            DataAccessApplication.MirrorApplicationLocationsAndDetailsToPermit(OrganizationService, newApplication.Id);

            // 6. Change app status to issued
            DataAccessIntegrationTestSupport.ChangeApplicationStatus(OrganizationService, application, defra_application_StatusCode.DulyMaking);
            DataAccessIntegrationTestSupport.ChangeApplicationStatus(OrganizationService, application, defra_application_StatusCode.Determination);
            DataAccessIntegrationTestSupport.ChangeApplicationStatus(OrganizationService, application, defra_application_StatusCode.PeerReview);
            DataAccessIntegrationTestSupport.ChangeApplicationStatus(OrganizationService, application, defra_application_StatusCode.Issued);


            // 7. Call MirrorApplicationSitesToPermit
            int appCount = DataAccessApplication.GetCountForApplicationsLinkedToPermit(
                OrganizationService,
                permitId,
                new[]
            {
                defra_application_StatusCode.Issued,
                defra_application_StatusCode.Withdrawn,
                defra_application_StatusCode.Issued,
                defra_application_StatusCode.Refused,
                defra_application_StatusCode.Returned,
                defra_application_StatusCode.ReturnedNotDulyMade
            });

            Assert.IsTrue(appCount == 0);



            // 8. Create Variation
            DataAccessIntegrationTestSupport.CreateApplication(OrganizationService, ApplicationTypes.Variation, permitId);


            // 9. Call MirrorApplicationSitesToPermit
            appCount = DataAccessApplication.GetCountForApplicationsLinkedToPermit(
                OrganizationService,
                permitId,
                new[]
            {
                defra_application_StatusCode.Issued,
                defra_application_StatusCode.Withdrawn,
                defra_application_StatusCode.Issued,
                defra_application_StatusCode.Refused,
                defra_application_StatusCode.Returned,
                defra_application_StatusCode.ReturnedNotDulyMade
            });

            Assert.IsTrue(appCount == 1);
        }