public void IsRelationshipCircular_returns_true_when_a_ticket_in_the_circle_has_no_identity([HasIdentity] DirectionalRelationship rel, [HasIdentity] Ticket ticket2, [HasIdentity] Ticket ticket3, [HasIdentity] TicketRelationship tr1, [HasIdentity] TicketRelationship tr2, [HasIdentity] TicketRelationship tr3, CircularRelationshipDetector sut) { var traversibleRelationships = new[] { new TraversibleRelationship(tr1.GetIdentity(), null, ticket2.GetIdentity(), rel.GetIdentity()), new TraversibleRelationship(tr2.GetIdentity(), ticket2.GetIdentity(), ticket3.GetIdentity(), rel.GetIdentity()), new TraversibleRelationship(tr3.GetIdentity(), ticket3.GetIdentity(), null, rel.GetIdentity()), }; var result = sut.IsRelationshipCircular(rel.GetIdentity(), traversibleRelationships); Assert.That(result, Is.True); }
public void A_user_can_add_a_hierarchical_ticket_relationship(Project project, Ticket childTicket, Ticket parentTicket, TicketType type, DirectionalRelationship parentChildRelationship, [FromDi] Lazy <IEntityData> data, [FromDi] Lazy <IGetsTransaction> tranFactory, [FromDi] Lazy <IHandlesEditTicketRequest> sut) { project.Code = "AddTicketRelationshipIntegrationTests.A_user_can_add_a_hierarchical_ticket_relationship"; parentChildRelationship.Behaviour.ProhibitCircularRelationship = true; parentChildRelationship.Behaviour.ProhibitMultipleSecondaryRelationships = false; childTicket.Project = project; childTicket.TicketNumber = 1; childTicket.Type = type; parentTicket.Project = project; parentTicket.TicketNumber = 2; parentTicket.Type = type; using (var tran = tranFactory.Value.GetTransaction()) { data.Value.Add(project); data.Value.Add(parentChildRelationship); data.Value.Add(parentTicket); data.Value.Add(type); tran.Commit(); } var editRequest = new EditTicketRequest { Identity = parentTicket.GetIdentity(), CommaSeparatedLabelNames = String.Empty, Description = "This is a description", SprintIdentity = null, Title = "This is a title", TicketTypeIdentity = type.GetIdentity(), RelationshipsToAdd = new [] { new AddRelationshipRequest { ParticipationType = RelationshipParticipant.Secondary, RelatedTicketReference = childTicket.GetTicketReference(), RelationshipId = parentChildRelationship.GetIdentity(), }, }, }; var result = sut.Value.Edit(editRequest); if (result?.IsSuccess != true) { var unsuccessfulRules = result.ValidationResult.RuleResults.Where(x => x.RuleResult.Outcome != RuleOutcome.Success); logger.Error($"Failed results are: {String.Join(", ", unsuccessfulRules.Select(x => $"{x.ManifestIdentity}: {x.RuleResult.Outcome}"))}"); } Assert.That(result?.IsSuccess, Is.True); }
public void IsRelationshipCircular_returns_false_when_a_complex_non_circular_relationship_hierarchy_exists([HasIdentity] DirectionalRelationship rel1, [HasIdentity] Ticket ticket1, [HasIdentity] Ticket ticket2, [HasIdentity] Ticket ticket3, [HasIdentity] Ticket ticket4, [HasIdentity] Ticket ticket5, [HasIdentity] TicketRelationship tr1, [HasIdentity] TicketRelationship tr2, [HasIdentity] TicketRelationship tr3, [HasIdentity] TicketRelationship tr4, [HasIdentity] TicketRelationship tr5, [HasIdentity] TicketRelationship tr6, [HasIdentity] TicketRelationship tr7, [Frozen, LoggerFor(typeof(CircularRelationshipDetector))] ILog logger, CircularRelationshipDetector sut) { var traversibleRelationships = new[] { new TraversibleRelationship(tr1.GetIdentity(), ticket1.GetIdentity(), ticket2.GetIdentity(), rel1.GetIdentity()), new TraversibleRelationship(tr2.GetIdentity(), ticket1.GetIdentity(), ticket3.GetIdentity(), rel1.GetIdentity()), new TraversibleRelationship(tr3.GetIdentity(), ticket1.GetIdentity(), ticket4.GetIdentity(), rel1.GetIdentity()), new TraversibleRelationship(tr4.GetIdentity(), ticket2.GetIdentity(), ticket3.GetIdentity(), rel1.GetIdentity()), new TraversibleRelationship(tr5.GetIdentity(), ticket2.GetIdentity(), ticket4.GetIdentity(), rel1.GetIdentity()), new TraversibleRelationship(tr6.GetIdentity(), ticket3.GetIdentity(), ticket4.GetIdentity(), rel1.GetIdentity()), new TraversibleRelationship(tr7.GetIdentity(), ticket4.GetIdentity(), ticket5.GetIdentity(), rel1.GetIdentity()), }; Assert.That(() => sut.IsRelationshipCircular(rel1.GetIdentity(), traversibleRelationships), Is.False); }
public void IsRelationshipCircular_returns_true_when_complex_circle_exists([HasIdentity] DirectionalRelationship rel, [HasIdentity] Ticket ticket1, [HasIdentity] Ticket ticket2, [HasIdentity] Ticket ticket3, [HasIdentity] Ticket ticket4, [HasIdentity] Ticket ticket5, [HasIdentity] TicketRelationship tr1, [HasIdentity] TicketRelationship tr2, [HasIdentity] TicketRelationship tr3, [HasIdentity] TicketRelationship tr4, [HasIdentity] TicketRelationship tr5, CircularRelationshipDetector sut) { var traversibleRelationships = new[] { new TraversibleRelationship(tr1.GetIdentity(), ticket1.GetIdentity(), ticket2.GetIdentity(), rel.GetIdentity()), new TraversibleRelationship(tr2.GetIdentity(), ticket2.GetIdentity(), ticket3.GetIdentity(), rel.GetIdentity()), new TraversibleRelationship(tr3.GetIdentity(), ticket2.GetIdentity(), ticket4.GetIdentity(), rel.GetIdentity()), new TraversibleRelationship(tr4.GetIdentity(), ticket5.GetIdentity(), ticket4.GetIdentity(), rel.GetIdentity()), new TraversibleRelationship(tr5.GetIdentity(), ticket4.GetIdentity(), ticket1.GetIdentity(), rel.GetIdentity()), }; var result = sut.IsRelationshipCircular(rel.GetIdentity(), traversibleRelationships); Assert.That(result, Is.True); }
public void A_user_may_add_a_relatinship_to_a_complex_multipath_directional_relationship_structure(Project project, Ticket editedTicket, Ticket blockedTicket1, Ticket blockedTicket2, Ticket blockedTicket3, Ticket blockedTicket4, Ticket parentTicket, TicketType type, DirectionalRelationship blocks, DirectionalRelationship childOf, [FromDi] Lazy <IEntityData> data, [FromDi] Lazy <IGetsTransaction> tranFactory, [FromDi] Lazy <IHandlesEditTicketRequest> sut) { /* The summary of the test data is that there are two directional relationships (block & child-of) * which prohibit circular relationships. The edited ticket blocks other tickets 1, 2 & 3. * Other ticket 1 blocks other tickets 2 & 3. Other ticket 2 blocks other ticket 3. Other ticket 3 * blocks other ticket 4. This is valid because the blocks flow in only one direction and cannot get * back to a parent ticket. * * In the test, we are adding a new child-of relationship to the edited ticket, making it a child of * the parent ticket. */ #region Setup test data project.Code = "AddTicketRelationshipIntegrationTests.A_user_may_add_a_relatinship_to_a_complex_multipath_directional_relationship_structure"; blocks.Behaviour.ProhibitCircularRelationship = true; blocks.Behaviour.ProhibitMultipleSecondaryRelationships = false; childOf.Behaviour.ProhibitCircularRelationship = true; childOf.Behaviour.ProhibitMultipleSecondaryRelationships = false; editedTicket.Project = project; editedTicket.TicketNumber = 1; editedTicket.Type = type; blockedTicket1.Project = project; blockedTicket1.TicketNumber = 2; blockedTicket1.Type = type; blockedTicket1.Project = project; blockedTicket1.TicketNumber = 3; blockedTicket1.Type = type; blockedTicket1.Project = project; blockedTicket1.TicketNumber = 4; blockedTicket1.Type = type; blockedTicket1.Project = project; blockedTicket1.TicketNumber = 5; blockedTicket1.Type = type; parentTicket.Project = project; parentTicket.TicketNumber = 6; parentTicket.Type = type; editedTicket.PrimaryRelationships.Add(new TicketRelationship { SecondaryTicket = blockedTicket1, Relationship = blocks }); editedTicket.PrimaryRelationships.Add(new TicketRelationship { SecondaryTicket = blockedTicket2, Relationship = blocks }); editedTicket.PrimaryRelationships.Add(new TicketRelationship { SecondaryTicket = blockedTicket3, Relationship = blocks }); blockedTicket1.PrimaryRelationships.Add(new TicketRelationship { SecondaryTicket = blockedTicket2, Relationship = blocks }); blockedTicket1.PrimaryRelationships.Add(new TicketRelationship { SecondaryTicket = blockedTicket3, Relationship = blocks }); blockedTicket2.PrimaryRelationships.Add(new TicketRelationship { SecondaryTicket = blockedTicket3, Relationship = blocks }); blockedTicket3.PrimaryRelationships.Add(new TicketRelationship { SecondaryTicket = blockedTicket4, Relationship = blocks }); using (var tran = tranFactory.Value.GetTransaction()) { data.Value.Add(project); data.Value.Add(blocks); data.Value.Add(childOf); data.Value.Add(editedTicket); data.Value.Add(parentTicket); data.Value.Add(type); tran.Commit(); } #endregion var editRequest = new EditTicketRequest { Identity = editedTicket.GetIdentity(), Title = "This is a title", TicketTypeIdentity = type.GetIdentity(), RelationshipsToAdd = new[] { new AddRelationshipRequest { ParticipationType = RelationshipParticipant.Secondary, RelatedTicketReference = parentTicket.GetTicketReference(), RelationshipId = childOf.GetIdentity(), }, }, }; var result = sut.Value.Edit(editRequest); if (result?.IsSuccess != true) { var unsuccessfulRules = result.ValidationResult.RuleResults.Where(x => x.RuleResult.Outcome != RuleOutcome.Success); logger.Error($"Failed results are: {String.Join(", ", unsuccessfulRules.Select(x => $"{x.ManifestIdentity}: {x.RuleResult.Outcome}"))}"); } Assert.That(result?.IsSuccess, Is.True); }
public void Equals_returns_false_for_object([HasIdentity] TicketRelationship ticketRel, [HasIdentity] DirectionalRelationship rel1) { var sut = new TraversibleRelationship(ticketRel.GetIdentity(), null, null, rel1.GetIdentity()); Assert.That(() => sut.Equals(new Object()), Is.False); }
public void Equals_returns_false_for_two_different_identities([HasIdentity] TicketRelationship ticketRel1, [HasIdentity] TicketRelationship ticketRel2, [HasIdentity] DirectionalRelationship rel1, [HasIdentity] DirectionalRelationship rel2) { var sut = new TraversibleRelationship(ticketRel1.GetIdentity(), null, null, rel1.GetIdentity()); var two = new TraversibleRelationship(ticketRel2.GetIdentity(), null, null, rel2.GetIdentity()); Assert.That(() => sut.Equals(two), Is.False); }