Example #1
0
        /// <summary>
        /// Fills a single slot with its filler.
        /// </summary>
        /// <returns>The element created by the operation.</returns>
        /// <param name="slotAndFiller">The slot and its filler.</param>
        public virtual IZptElement FillSlot(SlotToFill slotAndFiller)
        {
            var slot = slotAndFiller.Slot.Element;
              var filler = slotAndFiller.Filler.Element;

              var fillSlotAttribute = slot.GetMetalAttribute(ZptConstants.Metal.FillSlotAttribute);
              var replacement = slot.ReplaceWith(filler);

              if(fillSlotAttribute != null)
              {
            replacement.SetAttribute(ZptConstants.Metal.Namespace,
                                   ZptConstants.Metal.FillSlotAttribute,
                                   fillSlotAttribute.Value);
              }

              return replacement;
        }
        public void Setup()
        {
            _autoFixture = new Fixture();

              _contextOne = new Mock<IRenderingContext>();
              _contextTwo = new Mock<IRenderingContext>();

              _elementOne = new Mock<IZptElement>();
              _elementTwo = new Mock<IZptElement>();
              _elementThree = new Mock<IZptElement>();

              _contextOne.SetupGet(x => x.Element).Returns(_elementOne.Object);
              _contextTwo.SetupGet(x => x.Element).Returns(_elementTwo.Object);

              _elementOne.Setup(x => x.ReplaceWith(_elementTwo.Object)).Returns(_elementThree.Object);

              _slotAndFiller = new SlotToFill(_contextOne.Object, _contextTwo.Object, _autoFixture.Create<string>());

              _sut = new MacroExtensionSubstitutor();
        }
        /// <summary>
        /// Fills a single slot with its filler.
        /// </summary>
        /// <returns>The element created by the operation.</returns>
        /// <param name="slotAndFiller">The slot and its filler.</param>
        public override IZptElement FillSlot(SlotToFill slotAndFiller)
        {
            var slot = slotAndFiller.Slot.Element;
              var filler = slotAndFiller.Filler.Element;

              var replacement = base.FillSlot(slotAndFiller);

              var slotIsRedefined = filler.SearchChildrenByMetalAttribute(ZptConstants.Metal.DefineSlotAttribute)
            .Where(x => x.GetAttribute(ZptConstants.Metal.Namespace,
                                     ZptConstants.Metal.DefineSlotAttribute).Value == slotAndFiller.Name)
            .Any();

              if(!slotIsRedefined)
              {
            replacement.SetAttribute(ZptConstants.Metal.Namespace,
                                   ZptConstants.Metal.DefineSlotAttribute,
                                   slotAndFiller.Name);
              }

              return replacement;
        }