Exemple #1
0
        public void UpdateObjectSerialisationOmmitPostAttributeValueTest()
        {
            var personConsent = new UpdatePersonConsentLink(1)
            {
                ConsentGiven = true,
                ConsentedBy  = new Relationship <SimplePersonLink>(),
                Person       = new Relationship <SimplePersonLink>(),
                Consent      = new Relationship <SimpleConsentLink>()
            };

            personConsent.ConsentedBy.Data = new SimplePersonLink()
            {
                ID = 1
            };
            personConsent.Person.Data = new SimplePersonLink()
            {
                ID = 1
            };
            personConsent.Consent.Data = new SimpleConsentLink()
            {
                ID = 1
            };

            string valueEnrolmentJson = JsonConvert.SerializeObject(personConsent, _settings);

            Assert.AreEqual(valueEnrolmentJson, "{\"data\":{\"id\":\"1\",\"type\":\"personConsentLink\",\"attributes\":{\"consentGiven\":true},\"relationships\":{\"consentedBy\":{\"data\":{\"id\":\"1\",\"type\":\"person\"}}}}}", "Actual Property value test");
        }
Exemple #2
0
        // This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called
        protected override void ProcessRecord()
        {
            UpdatePersonConsentLink consentLink = GetInitUpdateModel();

            // Populate from student object if object was used.
            if (_consentedByProvided)
            {
                consentLink.ConsentedBy = new Relationship <SimplePersonLink>();
                if (_consentedBy != null)
                {
                    consentLink.ConsentedBy.Data = new SimplePersonLink()
                    {
                        ID = _consentedBy.ID
                    };
                }
            }
            if (_consentGivenProvided)
            {
                consentLink.ConsentGiven = _consentGiven;
            }

            var response = SentralApiClient.Enrolments.UpdatePersonConsentLink(consentLink);

            WriteObject(response);
        }
        public void CreateAndDeleteOneConsentLinkTest()
        {
            // Only run test on sandbox
            if (IsTestSite)
            {
                var consentedBy = new Relationship <SimplePersonLink>
                {
                    Data = new SimplePersonLink()
                    {
                        ID = 1
                    }
                };

                var consent = new Relationship <SimpleConsentLink>
                {
                    Data = new SimpleConsentLink()
                    {
                        ID = 1
                    }
                };

                var person = new Relationship <SimplePersonLink>
                {
                    Data = new SimplePersonLink()
                    {
                        ID = 1
                    }
                };


                var updateConsent = new UpdatePersonConsentLink()
                {
                    ConsentGiven = true,
                    ConsentedBy  = consentedBy,
                    Person       = person,
                    Consent      = consent
                };


                var response = SAPI.Enrolments.CreatePersonConsentLink(updateConsent);

                Assert.IsTrue(response != null);

                SAPI.Enrolments.DeletePersonConsentLink(response.ID);

                Assert.ThrowsException <RestClientException>(() => SAPI.Enrolments.GetPersonConsentLink(response.ID));
            }
        }
Exemple #4
0
        // This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called
        protected override void ProcessRecord()
        {
            var simpleConsent = new Relationship <SimpleConsentLink>()
            {
                Data = new SimpleConsentLink()
                {
                    ID = Consent.ID
                }
            };


            var simplePerson = new Relationship <SimplePersonLink>()
            {
                Data = new SimplePersonLink()
                {
                    ID = Person.ID
                }
            };

            UpdatePersonConsentLink consentLink = new UpdatePersonConsentLink()
            {
                ConsentGiven = ConsentGiven,
                Consent      = simpleConsent,
                Person       = simplePerson
            };



            if (_consentedByProvided && _consentedBy != null)
            {
                consentLink.ConsentedBy = new Relationship <SimplePersonLink>()
                {
                    Data = new SimplePersonLink()
                    {
                        ID = ConsentedBy.ID
                    }
                };
            }

            var response = SentralApiClient.Enrolments.CreatePersonConsentLink(consentLink);

            WriteObject(response);
        }