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"); }
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(); } }
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(); } }
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)); }
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."); }
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>(); }
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; }
/// <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); } }