public void get_by_id_returns_403_unauthorized_if_no_auth_header(
            Guid ticketId,
            [Frozen]Mock<IQuery<Guid, TicketDetails>> query,
            TicketsController sut)
        {
            query.Setup(q => q.Execute(It.IsAny<Envelope<Guid>>())).Throws<UnauthorizedAccessException>();

            var actual = sut.Get(ticketId);

            actual.Should().BeOfType<UnauthorizedResult>("because user name query returned nothing");
        }
        public void get_by_id_returns_404_NotFound_when_ticket_not_found(
            Guid ticketId,
            TicketNotFoundException notFound,
            [Frozen]Mock<IQuery<Guid, TicketDetails>> ticketQuery,
            TicketsController sut)
        {
            ticketQuery.Setup(q => q.Execute(It.Is<Envelope<Guid>>(t => t.Item == ticketId))).Throws(notFound);

            var actual = sut.Get(ticketId);

            actual.Should().BeOfType<NotFoundResult>("because TicketNotFoundException was thrown by query");
        }
        public void get_returns_tickets_returned_by_query(
            List<TicketDetails> tickets,
            [Frozen]Mock<IQuery<EmptyRequest, IEnumerable<TicketDetails>>> ticketsQuery,
            TicketsController sut)
        {
            ticketsQuery.Setup(q => q.Execute(It.IsAny<Envelope<EmptyRequest>>())).Returns(tickets);

            var actual = sut.Get();

            actual.Should().BeOfType<OkNegotiatedContentResult<TicketsModel>>()
                  .Which.Content.Tickets.Select(t => t.Title).Should().Equal(tickets.Select(t => t.Title));
        }
        public void get_returns_403_unauthorized_if_no_auth_header(
            [Frozen]Mock<IQuery<EmptyRequest, IEnumerable<TicketDetails>>> ticketsQuery,
            TicketsController sut)
        {
            ticketsQuery.Setup(q => q.Execute(It.IsAny<Envelope<EmptyRequest>>())).Throws<UnauthorizedAccessException>();

            var actual = sut.Get();

            actual.Should().BeOfType<UnauthorizedResult>("because user name query returned nothing");
        }
        public void get_by_id_returns_ticket_version_in_etag_header(
            Guid ticketId,
            TicketDetails ticket,
            [Frozen]Mock<IQuery<Guid, TicketDetails>> ticketQuery,
            TicketsController sut)
        {
            ticketQuery.Setup(q => q.Execute(It.Is<Envelope<Guid>>(t => t.Item == ticketId))).Returns(ticket);

            var actual = sut.Get(ticketId);

            actual.Should().BeOfType<OkResultWithETag<TicketResponseModel>>()
                  .Which.ETagValue.Should().Be(ticket.Version.ToString());
        }
        public void get_by_id_returns_ticket_returned_by_query(
            string userName,
            Guid ticketId,
            TicketDetails ticket,
            [Frozen]Mock<IQuery<Guid, TicketDetails>> ticketQuery,
            TicketsController sut)
        {
            ticketQuery.Setup(q => q.Execute(It.Is<Envelope<Guid>>(t => t.Item == ticketId))).Returns(ticket);

            var actual = sut.Get(ticketId);

            actual.Should().BeOfType<OkResultWithETag<TicketResponseModel>>()
                  .Which.Content.Should().ShouldBeEquivalentTo(ticket, options => options.ExcludingMissingMembers());
        }