public string Execute(Person personRoot, List <string> parameters)
        {
            if (parameters == null || parameters.Count < 2)
            {
                return("INVALID_COMMAND");
            }
            var personToSearchforRelatives = personRoot.GetFamilyMemberByName(parameters[0]);

            if (personToSearchforRelatives == null)
            {
                return("PERSON_NOT_FOUND");
            }
            var relationship = new RelationshipFactory().GetRelationship(parameters[1]);

            if (relationship == null)
            {
                return("INVALID_COMMAND");
            }

            var relativeNames = relationship.GetAll(personToSearchforRelatives);

            if (relativeNames != null && relativeNames.Count > 0)
            {
                var relatives = string.Join(" ", relativeNames);
                return(relatives);
            }
            return("NONE");
        }
示例#2
0
        public void badNameFactoryTest()
        {
            RelationshipFactory myFactory    = new RelationshipFactory();
            Relationship        relationship = myFactory.createRelationship("BadRelationship", new System.Drawing.Point(0, 0), new System.Drawing.Point(100, 100), false);

            if (relationship != null)
            {
                Assert.Fail();
            }
        }
示例#3
0
        public void goodNameFactoryTest()
        {
            RelationshipFactory myFactory    = new RelationshipFactory();
            Relationship        relationship = myFactory.createRelationship("Composition", new System.Drawing.Point(0, 0), new System.Drawing.Point(100, 100), false);

            if (!(relationship is Composition))
            {
                Assert.Fail();
            }
        }
示例#4
0
            public void GivenRelationshipTypeIsBreaks_ThenReturnIcebreakerEconomicCard()
            {
                // arrange
                var factory = new RelationshipFactory();

                // act
                var relationship = factory.Create(RelationshipType.Breaks, new Card(), new Card());

                // assert
                Assert.IsInstanceOfType(relationship, typeof(IcebreakerEconomicRelationship));
            }
示例#5
0
            public void GivenNullTarget_ThenThrowArgumentNullException()
            {
                // arrange
                var factory = new RelationshipFactory();

                // act
                factory.Create(RelationshipType.Breaks, new Card(), null);

                // assert
                Assert.Fail("ArgumentNullException should have been thrown.");
            }
示例#6
0
 public Main()
 {
     InitializeComponent();
     myFactory = new RelationshipFactory();
     myObjects = new List <AppLayer.Object>();
     graphics  = this.CreateGraphics();
     graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     SelectedRecPen             = new Pen(Color.Black);
     SelectedRecPen.Width       = 1.0F;
     SelectedRecPen.DashCap     = System.Drawing.Drawing2D.DashCap.Round;
     SelectedRecPen.DashPattern = new float[] { 2.0F, 1.0F };
     myCommands = new List <Command>();
 }
示例#7
0
            public void GivenOtherwise_ThenReturnRelationship()
            {
                // arrange
                var factory = new RelationshipFactory();
                var source  = new Card();
                var target  = new Card();

                // act
                var relationship = factory.Create(RelationshipType.IsBrokenBy, source, target);

                // assert
                Assert.IsNotInstanceOfType(relationship, typeof(IcebreakerEconomicRelationship));
                Assert.AreEqual(RelationshipType.IsBrokenBy, relationship.Type);
                Assert.AreEqual(source, relationship.Source);
                Assert.AreEqual(target, relationship.Target);
            }
 internal RelationshipDenseSelectionIterator(RelationshipFactory <R> factory)
 {
     this._factory = factory;
     this._next    = RelationshipSelections.UNINITIALIZED;
 }
示例#9
0
 /// <summary>
 /// Returns a multi-directed resource iterator given the provided node cursor, direction and relationship types.
 /// </summary>
 /// <param name="cursors"> A cursor factor used for allocating the needed cursors </param>
 /// <param name="node"> A node cursor positioned at the current node. </param>
 /// <param name="types"> The types of the relationship </param>
 /// <param name="factory"> factory for creating instance of generic type T </param>
 /// <returns> An iterator that allows traversing the relationship chain. </returns>
 public static ResourceIterator <T> AllIterator <T>(CursorFactory cursors, NodeCursor node, int[] types, RelationshipFactory <T> factory)
 {
     if (node.Dense)
     {
         RelationshipDenseSelectionIterator <T> selectionIterator = new RelationshipDenseSelectionIterator <T>(factory);
         SetupAllDense(selectionIterator, cursors, node, types);
         return(selectionIterator);
     }
     else
     {
         RelationshipSparseSelectionIterator <T> selectionIterator = new RelationshipSparseSelectionIterator <T>(factory);
         SetupAllSparse(selectionIterator, cursors, node, types);
         return(selectionIterator);
     }
 }