Beispiel #1
0
        public TicketsEntity ToBusinessEntity(ISystemDateTime timeProvider)
        {
            TicketsEntity entity = TicketsFactory.Create(this.PostByUserID, timeProvider);

            entity.Title          = string.Empty;
            entity.URL            = string.Empty;
            entity.CompanyID      = 0;
            entity.ContinueDate   = 0;
            entity.ConvertDelete  = (int)CovertDeleteState.Normal;
            entity.CreateUserName = string.Empty;
            entity.DeliveryDate   = timeProvider.Now;
            entity.Description    = string.Empty;
            entity.DevTsHours     = 0;
            entity.Hours          = timeProvider.Now.Hour;
            entity.ID             = 0;
            entity.IsEstimates    = false;
            entity.IsInternal     = false;
            entity.Priority       = (int)PriorityState.Normal;
            entity.ProjectID      = 0;
            entity.PublishDate    = timeProvider.Now;
            entity.QaTsHours      = 0;
            entity.SourceTicketID = 0;
            entity.StartDate      = timeProvider.Now;
            entity.Status         = 0;
            entity.TicketID       = 0;
            entity.TicketType     = Enum.GetName(typeof(TicketsType), TicketsType.Bug);

            entity.CreatedBy  = PostByUserID;
            entity.ModifiedBy = PostByUserID;
            entity.CreatedOn  = timeProvider.Now;
            entity.ModifiedOn = timeProvider.Now;
            return(entity);
        }
Beispiel #2
0
        public async Task GivenAnInexistentId_WhenDeleteAsync_ThenReturnFalse()
        {
            var ticket = TicketsFactory.ValidTicket();

            var result = await _repository.DeleteAsync(ticket.Id);

            result.Should().BeFalse();
        }
Beispiel #3
0
        public async Task GivenAnId_WhenDeleteAsync_ThenReturnTrue()
        {
            var ticket = TicketsFactory.AddedTicket(_database.DbContext);

            var result = await _repository.DeleteAsync(ticket.Id);

            result.Should().BeTrue();
        }
Beispiel #4
0
        public async Task GivenAnInexistentId_WhenGetByIdAsync_ThenReturnNull()
        {
            var ticket = TicketsFactory.ValidTicket();

            var result = await _repository.GetByIdAsync(ticket.Id);

            result.Should().BeNull();
        }
Beispiel #5
0
        public async Task GivenAnUserIdAndConsultantId_WhenGetByUserIdAndConsultantIdAsync_ThenReturnAnTicket()
        {
            var ticket = TicketsFactory.AddedTicket(_database.DbContext);

            var result = await _repository.GetByUserIdAndConsultantIdAsync(ticket.UserId, ticket.ConsultantId);

            result.Should().NotBeNull();
            result.Should().BeOfType <Ticket>();
        }
Beispiel #6
0
        public async Task GivenATicket_WhenCreateAsync_ThenReturnTicketEntity()
        {
            var ticket = TicketsFactory.ValidTicket();


            var result = await _repository.CreateAsync(ticket);

            result.Should().BeOfType <Ticket>();
        }
Beispiel #7
0
        public async Task GivenATicket_WhenUpdate_ThenReturnTicketUpdated()
        {
            var ticket        = TicketsFactory.AddedTicket(_database.DbContext);
            var updatedTicket = TicketsFactory.UpdateValidTicket(ticket.UserId, ticket.ConsultantId);

            var result = await _repository.UpdateAsync(updatedTicket);

            result.Should().BeOfType <Ticket>();
        }
Beispiel #8
0
        public async Task GivenAnStatus_WhenGetAllByStatusAsync_ThenReturnAnListOfTickets()
        {
            var ticket = TicketsFactory.Added2Tickets(_database.DbContext);

            var result = await _repository.GetAllByStatusAsync(ticket.Status);

            result.Should().BeOfType <List <Ticket> >();
            var addedTicket = result.FirstOrDefault(u => u.Status == ticket.Status);

            addedTicket.Should().NotBeNull();
        }
Beispiel #9
0
        public async Task GivenAListOfTickets_WhenGetAllTickets_ThenReturnListOfTicketsEntity()
        {
            var ticket = TicketsFactory.Added2Tickets(_database.DbContext);

            var result = await _repository.GetAllAsync();

            result.Should().BeOfType <List <Ticket> >();
            var addedTicket = result.FirstOrDefault(u => u.Id == ticket.Id);

            addedTicket.Should().NotBeNull();
        }
        public async Task GivenAnId_WhenDeleteTicketByIdCommandHandler_ThenReturnTrue()
        {
            var ticket   = TicketsFactory.ValidTicket();
            var command  = new DeleteTicketByIdCommand(ticket.Id);
            var mockRepo = new Mock <ITicketRepository>();

            mockRepo.Setup(db => db.DeleteAsync(command.Id).Result).Returns(true);
            var handler = new DeleteTicketByIdCommandHandler(mockRepo.Object);

            var result = await handler.Handle(command, CancellationToken.None);

            result.Should().BeTrue();
        }
Beispiel #11
0
        public async Task GivenAList_WhenGetAllTicketsQueryHandler_ThenReturnNotNull()
        {
            var ticket1 = TicketsFactory.ValidTicket();
            var ticket2 = TicketsFactory.ValidTicket();
            var tickets = new List <Ticket> {
                ticket1, ticket2
            };
            var command  = new GetAllTicketsQuery();
            var mockRepo = new Mock <ITicketRepository>();

            mockRepo.Setup(db => db.GetAllAsync().Result).Returns(tickets);
            var handler = new GetAllTicketsQueryHandler(mockRepo.Object);

            var result = await handler.Handle(command, CancellationToken.None);

            result.Should().NotContainNulls();
            result.Should().HaveCount(tickets.Count);
            result.Should().Contain(ticket1);
        }
Beispiel #12
0
 // Used to demonstrate factory
 public Raffle(TicketsFactory ticketsFactory)
 {
     this.tickets = ticketsFactory.CreateTickets();
 }