public void GetTicketDetailDto_returns_null_when_the_reference_is_null([Frozen] IGetsTicketByReference ticketProvider,
                                                                               TicketDetailDtoProvider sut)
        {
            Mock.Get(ticketProvider)
            .Setup(x => x.GetTicketByReference((TicketReference)null))
            .Returns(() => null);
            var result = sut.GetTicketDetailDto(null);

            Assert.That(result, Is.Null);
        }
        public void GetWorkLog_returns_failure_result_if_ticket_query_returns_null(AddWorkLogRequest request,
                                                                                   [Frozen] IGetsTicketByReference ticketQuery,
                                                                                   TicketWorkLogFactory sut)
        {
            Mock.Get(ticketQuery).Setup(x => x.GetTicketByReference(It.IsAny <TicketReference>())).Returns(() => null);
            var result = sut.GetWorkLog(request);

            Assert.That(result?.Success, Is.False);
            Assert.That(result?.TicketNotFound, Is.True);
        }
Example #3
0
 public TicketWorkLogFactory(IParsesTimespan timespanParser, IGetsTicketByReference ticketProvider)
 {
     if (ticketProvider == null)
     {
         throw new ArgumentNullException(nameof(ticketProvider));
     }
     if (timespanParser == null)
     {
         throw new ArgumentNullException(nameof(timespanParser));
     }
     this.timespanParser = timespanParser;
     this.ticketProvider = ticketProvider;
 }
 public TicketRelationshipFactory(IEntityData data, IGetsTicketByReference ticketQuery)
 {
     if (ticketQuery == null)
     {
         throw new ArgumentNullException(nameof(ticketQuery));
     }
     if (data == null)
     {
         throw new ArgumentNullException(nameof(data));
     }
     this.data        = data;
     this.ticketQuery = ticketQuery;
 }
Example #5
0
 public TicketDetailDtoProvider(IGetsTicketByReference ticketProvider, IMapper mapper, IEntityData data)
 {
     if (data == null)
     {
         throw new ArgumentNullException(nameof(data));
     }
     if (mapper == null)
     {
         throw new ArgumentNullException(nameof(mapper));
     }
     if (ticketProvider == null)
     {
         throw new ArgumentNullException(nameof(ticketProvider));
     }
     this.ticketProvider = ticketProvider;
     this.mapper         = mapper;
     this.data           = data;
 }
        public void GetTicketDetailDto_returns_mapped_dto_when_ticket_exists([Frozen] IGetsTicketByReference ticketProvider,
                                                                             [Frozen, InMemory] IEntityData data,
                                                                             [Frozen] IMapper mapper,
                                                                             TicketDetailDtoProvider sut,
                                                                             TicketReference reference,
                                                                             TicketDetailDto dto,
                                                                             Ticket ticket)
        {
            Mock.Get(ticketProvider)
            .Setup(x => x.GetTicketByReference(reference))
            .Returns(ticket);
            data.Add(ticket);
            Mock.Get(mapper)
            .Setup(x => x.Map <TicketDetailDto>(ticket))
            .Returns(dto);
            var result = sut.GetTicketDetailDto(reference);

            Assert.That(result, Is.SameAs(dto));
        }
Example #7
0
        public TicketController(IGetsTicketDetailDtoByReference ticketDetailProvider,
                                Lazy <IHandlesEditTicketRequest> editor,
                                Lazy <IGetsEditTicketModel> editTicketModelFactory,
                                IMapper mapper,
                                ILog logger,
                                IGetsTicketByReference ticketProvider)
        {
            if (ticketProvider == null)
            {
                throw new ArgumentNullException(nameof(ticketProvider));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (editTicketModelFactory == null)
            {
                throw new ArgumentNullException(nameof(editTicketModelFactory));
            }
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }
            if (editor == null)
            {
                throw new ArgumentNullException(nameof(editor));
            }
            if (ticketDetailProvider == null)
            {
                throw new ArgumentNullException(nameof(ticketDetailProvider));
            }

            this.mapper                 = mapper;
            this.logger                 = logger;
            this.ticketProvider         = ticketProvider;
            this.ticketDetailProvider   = ticketDetailProvider;
            this.editor                 = editor;
            this.editTicketModelFactory = editTicketModelFactory;
        }
 public TheoreticalRelationshipProvider(IEntityData data, IGetsTicketByReference ticketProvider, ILog logger)
 {
     this.data           = data ?? throw new ArgumentNullException(nameof(data));
     this.ticketProvider = ticketProvider ?? throw new ArgumentNullException(nameof(ticketProvider));
     this.logger         = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public TicketIdentityFromTicketReferenceProvider(IGetsTicketByReference ticketProvider)
 {
     this.ticketProvider = ticketProvider ?? throw new ArgumentNullException(nameof(ticketProvider));
 }
        public void GetWorkLog_returns_success_result_with_correct_values_from_services(AddWorkLogRequest request,
                                                                                        [Frozen] IParsesTimespan timespanParser,
                                                                                        [Frozen] IGetsTicketByReference ticketQuery,
                                                                                        int minutes,
                                                                                        Ticket ticket,
                                                                                        TicketWorkLogFactory sut)
        {
            Mock.Get(ticketQuery).Setup(x => x.GetTicketByReference(request.TicketReference)).Returns(ticket);
            Mock.Get(timespanParser).Setup(x => x.GetTimeSpan(request.TimeSpent)).Returns(() => TimeSpan.FromMinutes(minutes));

            var result = sut.GetWorkLog(request);

            Assert.That(result?.Success, Is.True);
            Assert.That(result?.WorkLog?.User, Is.SameAs(request.User));
            Assert.That(result?.Ticket, Is.SameAs(ticket));
            Assert.That(result?.WorkLog?.Ticket, Is.Null);
            Assert.That(result?.WorkLog?.GetTimeSpent().TotalMinutes, Is.EqualTo(minutes));
            Assert.That(result?.WorkLog?.TimeStarted, Is.EqualTo(request.TimeStarted));
        }
        public void CreateTicketRelationship_sets_up_primary_ticket_when_participation_is_secondary([Frozen] IGetsTicketByReference refQuery,
                                                                                                    IIdentity <Relationship> relationshipId,
                                                                                                    TicketReference ticketReference,
                                                                                                    Ticket relatedTicket,
                                                                                                    TicketRelationshipFactory sut)
        {
            // Arrange
            Mock.Get(refQuery).Setup(x => x.GetTicketByReference(ticketReference)).Returns(relatedTicket);

            // Act
            var result = sut.CreateTicketRelationship(relationshipId, ticketReference, RelationshipParticipant.Secondary);

            // Assert
            Assert.That(result?.PrimaryTicket, Is.SameAs(relatedTicket));
        }