public void WithLabel_Sets_Label()
        {
            var element = new RecordElement("name");
            Assert.IsNotNull(new RecordElementExpression(element).WithLabel("customLabel"));

            Assert.AreEqual(element.Label, "customLabel");
        }
        public void ToDot_Should_Use_Name_As_Label_If_No_Label_Specified() {
            var element = new RecordElement("recordName");
            Assert.AreEqual(element.ToDot(), @"<recordName> recordName");

            element.Label = String.Empty;
            Assert.AreEqual(element.ToDot(), @"<recordName> recordName");
        }
        public void IsInverted_Sets_Inverted()
        {
            var element = new RecordElement("name");
            Assert.IsNotNull(new RecordElementExpression(element).IsInverted());

            Assert.AreEqual(element.IsInverted, true);
        }
        public void AddElement_Adds_Element_To_Group()
        {
            var element = new RecordElement("b");

            var group = new RecordGroup();
            Assert.AreEqual(group.Elements.Count, 0);
            group.AddElement(element);
            Assert.AreEqual(group.Elements.Count, 1);
        }
        public void Add_Adds_Item_To_Tracker()
        {
            var element = new RecordElement("a");
            var tracker = new ElementTracker();

            Assert.IsFalse(tracker.ContainsElement("a"));
            tracker.AddElement(element);
            Assert.IsTrue(tracker.ContainsElement("a"));

            Assert.AreEqual(tracker.Elements.Count(), 1);
            Assert.AreSame(tracker.Elements.First(), element);
        }
Exemple #6
0
        /// <summary>
        /// Adds an element to the group with the specified name and label.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="elementConfiguration">The element configuration.</param>
        /// <returns>The current expression instance.</returns>
        public IRecordExpression WithElement(string name, Action<IRecordElementExpression> elementConfiguration)  
        {
            var element = new RecordElement(name);

            if (elementConfiguration != null)
            {
                elementConfiguration(new RecordElementExpression(element));
            }

            group.AddElement(element);
            
            return this;
        }
 public void ToDot_Should_Produce_Correct_Output()
 {
     var element = new RecordElement("recordName") {Label = "recordLabel"};
     Assert.AreEqual(element.ToDot(), "<recordName> recordLabel");
 }
 public void ToDot_Should_Escape_Bad_Characters()
 {
     var element = new RecordElement("recordName") { Label = "<{record | | Label}>" };
     Assert.AreEqual(element.ToDot(), @"<recordName> \<\{record\ \|\ \|\ Label\}\>");
 }
 public void IsInverted_Should_Surround_With_Curly_Braces()
 {
     var element = new RecordElement("recordName") { IsInverted = true };
     Assert.AreEqual(element.ToDot(), @"{<recordName> recordName}");
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RecordElementExpression"/> class.
 /// </summary>
 /// <param name="recordElement">The record element.</param>
 public RecordElementExpression(RecordElement recordElement)
 {
     this.recordElement = recordElement;
 }