コード例 #1
0
        public void InheritedAttributes_SetAttributeOnParentEntity_SetsValueForChildEntity()
        {
            var rockContext          = new RockContext();
            var eventItemService     = new EventItemService(rockContext);
            var eventCalendarService = new EventCalendarItemService(rockContext);

            // Setting the value of an inherited Attribute should persist the value for the child entity.
            var eventA = eventItemService.Get(EventAGuid.AsGuid());

            eventA.LoadAttributes(rockContext);
            eventA.SetAttributeValue(InternalCalendarAttribute1Key, "xyzzy");

            // TODO: SaveAttributeValues does not correctly save inherited values.
            // It wrongly attributes them to the entity on which they are set rather than the inherited entity.
            eventA.SaveAttributeValues(rockContext);

            var calendarItemInternal = eventCalendarService.Get(EventACalendarInternalGuid.AsGuid());
            var calendarItemPublic   = eventCalendarService.Get(EventACalendarPublicGuid.AsGuid());

            calendarItemInternal.LoadAttributes();
            Assert.IsTrue(calendarItemInternal.AttributeValues[InternalCalendarAttribute1Key].Value == "xyzzy");
            calendarItemPublic.LoadAttributes();
            Assert.IsTrue(calendarItemPublic.AttributeValues[InternalCalendarAttribute1Key].Value == "xyzzy");
        }