public void Equals_returns_true_for_two_equal_identities([HasIdentity] TicketRelationship ticketRel, [HasIdentity] DirectionalRelationship rel1, [HasIdentity] DirectionalRelationship rel2) { var sut = new TraversibleRelationship(ticketRel.GetIdentity(), null, null, rel1.GetIdentity()); var two = new TraversibleRelationship(ticketRel.GetIdentity(), null, null, rel2.GetIdentity()); Assert.That(() => sut.Equals(two), Is.True); }
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 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 Edit_can_remove_two_secondary_relationships_which_are_unwanted(Ticket ticket, EditTicketRequest request, [HasIdentity] TicketRelationship firstRelationship, [HasIdentity] TicketRelationship secondRelationship, [HasIdentity] TicketRelationship thirdRelationship, RelationshipRemovingTicketEditorDecorator sut) { // Arrange ticket.SecondaryRelationships.Clear(); ticket.SecondaryRelationships.Add(firstRelationship); ticket.SecondaryRelationships.Add(secondRelationship); ticket.SecondaryRelationships.Add(thirdRelationship); request.RelationshipsToRemove.Clear(); request.RelationshipsToRemove.Add(new DeleteRelationshipRequest { TicketRelationshipId = firstRelationship.GetIdentity() }); request.RelationshipsToRemove.Add(new DeleteRelationshipRequest { TicketRelationshipId = secondRelationship.GetIdentity() }); // Act sut.Edit(ticket, request); // Assert Assert.That(ticket.SecondaryRelationships, Is.EquivalentTo(new [] { thirdRelationship })); }
TheoreticalRelationship MapToTheoreticalRelationship(TicketRelationship tr) { return(new TheoreticalRelationship { PrimaryTicket = tr.PrimaryTicket.GetIdentity(), SecondaryTicket = tr.SecondaryTicket.GetIdentity(), TicketRelationship = tr.GetIdentity(), Relationship = tr.Relationship, Type = TheoreticalRelationshipType.Existing, }); }
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 GetTheoreticalTicketRelationships_marks_up_relationships_for_removal([Frozen, InMemory] IEntityData data, Ticket ticket, [WithRelationship] IEnumerable <TicketRelationship> relationships, TicketRelationship toRemove, TheoreticalRelationshipProvider sut) { data.Add(ticket); foreach (var t in relationships.Select(x => x.PrimaryTicket)) { data.Add(t); } foreach (var relationship in relationships) { data.Add(relationship); } data.Add(toRemove); ticket.SecondaryRelationships.ReplaceContents(relationships); ticket.SecondaryRelationships.Add(toRemove); var expected = relationships .Select(x => new TheoreticalRelationship { PrimaryTicket = x.PrimaryTicket.GetIdentity(), SecondaryTicket = ticket.GetIdentity(), Relationship = x.Relationship, TicketRelationship = x.GetIdentity(), }) .Append(new TheoreticalRelationship { PrimaryTicket = toRemove.PrimaryTicket?.GetIdentity(), SecondaryTicket = toRemove.SecondaryTicket?.GetIdentity(), Relationship = toRemove.Relationship, TicketRelationship = toRemove.GetIdentity(), Type = TheoreticalRelationshipType.Removed, }) .ToList(); var result = sut.GetTheoreticalTicketRelationships(ticket.GetIdentity(), removed: new[] { new DeleteRelationshipRequest { TicketRelationshipId = toRemove.GetIdentity() } }); Assert.That(result, Is.EquivalentTo(expected)); }
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); }
TicketRelationshipDto GetRelationship(TicketRelationship relationship, RelationshipParticipant participant, IGetsRelationshipSummary summaryProvider, ResolutionContext ctx) { Ticket relatedTicket; if (participant == RelationshipParticipant.Primary) { relatedTicket = relationship.SecondaryTicket; } else { relatedTicket = relationship.PrimaryTicket; } return(new TicketRelationshipDto { Id = relationship.GetIdentity(), RelationshipId = relationship.Relationship?.GetIdentity(), Summary = summaryProvider.GetSummary(relationship.Relationship, participant), Participant = participant, RelatedTicket = ctx.Mapper.Map <TicketSummaryDto>(relatedTicket), }); }