Пример #1
0
 public void ToDot_Must_Produce_Correct_Output()
 {
     var recordGroup = new RecordGroup(new RecordElement("name"));
     Assert.AreEqual(
         new RecordNode("nodeName", recordGroup).ToDot(),
         "\"nodeName\" [shape=record, label=\"" + recordGroup.ToDot() + "\"]");
 }
 public void WithElement_Should_Throw_For_Duplicate_Elements()
 {
     var recordGroup = new RecordGroup();
     var expression = new RecordExpression(recordGroup);
     expression.WithElement("a");
     expression.WithElement("a");
 }
Пример #3
0
 public void HasRoundedCorners_Changes_Shape_To_Mrecord()
 {
     var recordGroup = new RecordGroup(new RecordElement("name"));
     Assert.AreEqual(
         new RecordNode("nodeName", recordGroup) { HasRoundedCorners = true }.ToDot(),
         "\"nodeName\" [shape=Mrecord, label=\"" + recordGroup.ToDot() + "\"]");
 }
 public void WithElement_Applies_Custom_Configuration()
 {
     var recordGroup = new RecordGroup();
     var expression = new RecordExpression(recordGroup);
     Assert.IsNotNull(expression.WithElement("elementName", x => x.WithLabel("bla")));
     Assert.AreEqual(recordGroup.Elements.Count, 1);
     Assert.AreEqual(((RecordElement)recordGroup.Elements[0]).Label, "bla");
 }
Пример #5
0
        public void ToDot_Should_Produce_Correct_Output_With_Mixed_Groups() {
            var group = new RecordGroup(
                new RecordGroup(new RecordElement("name1"), new RecordGroup(new RecordElement("name2"), new RecordElement("name3")) { IsInverted = true }),
                new RecordGroup(new RecordElement("name4"), new RecordElement("name5"))
                );

            Assert.AreEqual(group.ToDot(), "<name1> name1|{<name2> name2|<name3> name3}|<name4> name4|<name5> name5");
        }
 public void WithElement_Adds_New_Element()
 {
     var recordGroup = new RecordGroup();
     var expression = new RecordExpression(recordGroup);
     Assert.IsNotNull(expression.WithElement("elementName"));
     Assert.AreEqual(recordGroup.Elements.Count, 1);
     Assert.AreEqual(((RecordElement)recordGroup.Elements[0]).Name, "elementName");
 }
        /// <summary>
        /// Adds a record node with the specified name to the graph.
        /// </summary>
        /// <param name="name">The name of the record node to create.</param>
        /// <returns>
        /// A record expression for configuring the record.
        /// </returns>
        public IRootRecordExpression WithName(string name) {
            var recordGroup = new RecordGroup();
            var node = new RecordNode(name, recordGroup);
            
            graph.AddNode(node);

            var expression = new RootRecordExpression(node);
            return expression;
        }
Пример #8
0
        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);
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RecordGroup"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="group">The group of elements to add.</param>
        public RecordNode(string name, RecordGroup group)
            : base(name) {

            if (group == null) {
                throw new ArgumentNullException("group");
            }

            this.group = group;

            ElementTracker = group.ElementTracker;
            }
        public void Customize_Should_Apply_Configuration_To_Node()
        {
            var graph = MockRepository.GenerateMock<IGraph>();
            var group = new RecordGroup();
            var node = new RecordNode("a", group);

            Assert.AreEqual(node.Attributes.CurrentAttributes.Count, 0);

            new RootRecordExpression(node).Customize(x => x.WithColor(Color.Black));

            Assert.AreEqual(node.Attributes.CurrentAttributes.Count, 1);
        }
Пример #11
0
        /// <summary>
        /// Adds a group to this record.
        /// </summary>
        /// <param name="groupContentConfiguration">The group content configuration.</param>
        /// <param name="groupConfiguration">The group configuration.</param>
        /// <returns>The current expression instance.</returns>
        public IRecordExpression WithGroup(Action<IRecordExpression> groupContentConfiguration, Action<IRecordGroupExpression> groupConfiguration)
        {
            if (groupContentConfiguration != null) {
                var nestedGroup = new RecordGroup(group.ElementTracker);
                var expression = new RecordExpression(nestedGroup);
                groupContentConfiguration(expression);

                if (nestedGroup.Elements.Count > 0) {
                    group.AddElement(nestedGroup);
                }

                if (groupConfiguration != null)
                {
                    groupConfiguration(new RecordGroupExpression(nestedGroup));
                }
            }

            return this;
        }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RecordExpression"/> class.
 /// </summary>
 /// <param name="group">The group.</param>
 public RecordExpression(RecordGroup group)
 {
     this.group = group;
 }
Пример #13
0
 public void IsInverted_Sets_Group_as_Inverted()
 {
     var group = new RecordGroup();
     Assert.IsNotNull(new RecordGroupExpression(group).IsInverted());
     Assert.IsTrue(group.IsInverted);
 }
Пример #14
0
 public void ToDot_Should_Produce_Correct_Output_With_Single_Element()
 {
     var group = new RecordGroup(new RecordElement("name"));
     Assert.AreEqual(group.ToDot(), "<name> name");
 }
Пример #15
0
 public void ToDot_Should_Produce_Correct_Output_With_Multiple_Elements()
 {
     var group = new RecordGroup(new RecordElement("name1"), new RecordElement("name2"));
     Assert.AreEqual(group.ToDot(), "<name1> name1|<name2> name2");
 }
Пример #16
0
 public void ToDot_Should_Produce_Correct_Output_With_Inverted_Group()
 {
     var group = new RecordGroup(new RecordElement("name1"), new RecordElement("name2")) { IsInverted = true };
     Assert.AreEqual(group.ToDot(), "{<name1> name1|<name2> name2}");
 }