{
  [Collection("GraphQL")]
  public class EventExcludedArtistsTests
  {
    private readonly GraphQLHttpClient _graphQLClient;
    private readonly AreaDbHelper _areaDbHelper;
    private readonly UserDbHelper _userDbHelper;
    private readonly VenueDbHelper _venueDbHelper;
    private readonly ArtistDbHelper _artistDbHelper;

    private readonly EventDbHelper _eventDbHelper;
    private readonly ExcludedArtistsDbHelper _excludedArtistDbHelper;
    private readonly IDbConnectionFactory _dbConnectionFactory;

    public EventExcludedArtistsTests(GraphQLFixture fixture)
    {
      var userId = CreateUser(fixture).Result;
      _graphQLClient = fixture.WebApplicationFactory
        .CreateGraphQLHttpClient()
        .SetAuthenticatedUser(userId)
        .SetHeader("Cache-Control", "no-cache");

      _areaDbHelper = fixture.WebApplicationFactory.GetDbHelper<AreaDbHelper>();

      _userDbHelper = fixture.WebApplicationFactory.GetDbHelper<UserDbHelper>();
      _venueDbHelper = fixture.WebApplicationFactory.GetDbHelper<VenueDbHelper>();
      _artistDbHelper = fixture.WebApplicationFactory.GetDbHelper<ArtistDbHelper>();
      _eventDbHelper = fixture.WebApplicationFactory.GetDbHelper<EventDbHelper>();
      _excludedArtistDbHelper =
        fixture.WebApplicationFactory.GetDbHelper<ExcludedArtistsDbHelper>();
      _dbConnectionFactory = fixture.WebApplicationFactory.DbConnectionFactory;
    }

    private async Task<int> CreateUser(GraphQLFixture fixture)
    {
      var userDbHelper = fixture.WebApplicationFactory.GetDbHelper<UserDbHelper>();
      var areaDbHelper = fixture.WebApplicationFactory.GetDbHelper<AreaDbHelper>();
      var area = await areaDbHelper.Insert();
      var user = await userDbHelper.Insert(
        user => user.WithEventAccess(EventAccessLevelType.StandardUser).WithAreaId(area.Id)
      );
      return user.Id;
    }

    [Fact]
    public async Task ExcludedArtistsReturnedOnEvent()
    {
      // Arrange
      var venueId = await InsertPrequisiteData();

      var artist = await _artistDbHelper.Insert();
      var excludedArtist = await _artistDbHelper.Insert();

      // Create event with the artists
      var eventId = await InsertEventInDb(venueId, GenerateLineup(artist, excludedArtist));

      // Exclude exludedArtist
      await _excludedArtistDbHelper.InsertExcludedArtist(excludedArtist.Id, eventId);

      // Act - get the event
      var @event = await GetEvent(eventId);

      // Assert
      var excludedArtistActual = Assert.Single(@event.ExcludedArtists);
      Assert.Equal(excludedArtist.Id.ToString(), excludedArtistActual.Id);
    }

    [Fact]
    public async Task ExcludedArtistsFilteredFromLineupAndRevisionsLineup()
    {
      // Arrange
      var venueId = await InsertPrequisiteData();

      var artist = await _artistDbHelper.Insert();
      var excludedArtist = await _artistDbHelper.Insert();
      string inputLineup = GenerateLineup(artist, excludedArtist);
      string expectedLineup = GenerateLineup(artist) + $" and {excludedArtist.Name}";

      // Create event with the artists
      var eventId = await InsertEventInDb(venueId, inputLineup);

      // Exclude exludedArtist
      await _excludedArtistDbHelper.InsertExcludedArtist(excludedArtist.Id, eventId);

      // Act - get the event
      var @event = await GetEvent(eventId);

      // Assert
      Assert.Equal(expectedLineup, @event.Lineup);

      var revision = Assert.Single(@event.Revisions);
      Assert.Equal(HttpUtility.HtmlDecode(expectedLineup), revision.Event.Lineup);
    }

    [Fact]
    public async Task ExcludedArtistsFilteredFromEventArtistsAndRevisionsArtistsArrays()
    {
      // Arrange
      var venueId = await InsertPrequisiteData();

      var includedArtist = await _artistDbHelper.Insert();
      var excludedArtist = await _artistDbHelper.Insert();
      string inputLineup = GenerateLineup(includedArtist, excludedArtist);

      // Create event with the artists
      var eventId = await InsertEventInDb(venueId, inputLineup);

      // Exclude exludedArtist
      await _excludedArtistDbHelper.InsertExcludedArtist(excludedArtist.Id, eventId);

      // Act - get the event
      var @event = await GetEvent(eventId);

      // Assert
      var actualArtist = Assert.Single(@event.Artists);
      Assert.Equal(includedArtist.Id.ToString(), actualArtist.Id);

      var revision = Assert.Single(@event.Revisions);
      var revisionArtist = Assert.Single(revision.Event.Artists);
      Assert.Equal(includedArtist.Id.ToString(), revisionArtist.Id);
    }

    [Fact]
    public async Task ArtistsRemainExcludedWhenEventRevisionIsSet()
    {
      // Arrange

      var venueId = await InsertPrequisiteData();

      var includedArtist = await _artistDbHelper.Insert();
      var excludedArtist = await _artistDbHelper.Insert();
      string inputLineup = GenerateLineup(includedArtist, excludedArtist);

      // Create event with the artists
      int eventId = await InsertEventInDb(venueId, inputLineup);

      // Exclude exludedArtist
      await _excludedArtistDbHelper.InsertExcludedArtist(excludedArtist.Id, eventId);

      var @event = await GetEvent(eventId);

      // Event revision
      var eventRevisionInput = new EventInputDto
      {
        VenueId = venueId,
        Title = "Event Tile Updated",
        StartTime = new DateTime(2022, 2, 22),
        EndTime = new DateTime(2022, 2, 23),
        Lineup = inputLineup,
        Visibility = VisibilityType.Public
      };

      // Act
      await EventRevisionMutationTestHelpers.CreateEventRevisionMutation(
        _graphQLClient,
        eventRevisionInput,
        int.Parse(@event.Id)
      );

      // Assert
      @event = await GetEvent(eventId);

      Assert.Equal(2, @event.Revisions.Count());
      Assert.Collection(
        @event.Revisions,
        item1 =>
        {
          var a1 = Assert.Single(item1.Event.Artists);
          Assert.Equal(includedArtist.Id.ToString(), a1.Id);
        },
        item2 =>
        {
          var a2 = Assert.Single(item2.Event.Artists);
          Assert.Equal(includedArtist.Id.ToString(), a2.Id);
        }
      );

      // Check the DB too
      var eventArtists = await DbHelper.GetAsync<TblEventArtist>(
        _dbConnectionFactory,
        t => t.EventId == eventId
      );

      var eventArtistInDb = Assert.Single(eventArtists);
      Assert.Equal(includedArtist.Id, eventArtistInDb.DJID);
    }

    private async Task<EventResponse> GetEvent(int eventId)
    {
      var request = GetGraphQLRequest(eventId);
      var eventResponse = await _graphQLClient.SendQueryAsync(
        request,
        () => new { eventResponse = new EventResponse() }
      );

      eventResponse.AssertGraphQLWasSuccessful();
      return eventResponse.Data.eventResponse;
    }

    private static GraphQLRequest GetGraphQLRequest(int eventId) =>
      new GraphQLRequest
      {
        Query =
          @"
          query GET_EVENT($eventId: ID!) {
            eventResponse: event(id: $eventId) {
              id
              lineup
              artists {
                id
                name
              }
              excludedArtists {
                id
                name
              }
              revisions {
                id
                event {
                  lineup
                  artists {
                    id
                  }
                }
              }
            }
          }
        ",
        Variables = new { eventId }
      };

    private async Task<int> InsertEventInDb(int venueId, string lineup)
    {
      var eventInputDto = new EventInputDto
      {
        VenueId = venueId,
        Title = "Event Tile",
        StartTime = new DateTime(2022, 2, 22),
        EndTime = new DateTime(2022, 2, 23),
        Lineup = lineup,
        SubmissionSource = EventSubmissionSource.SubmitEventPage,
        Visibility = VisibilityType.Public,
      };

      var @event = await EventMutationTestHelpers.CreateEventMutation(
        _graphQLClient,
        eventInputDto
      );
      return int.Parse(@event.Data.Id);
    }

    private async Task<int> InsertPrequisiteData()
    {
      var areaDto = await _areaDbHelper.Insert();
      var userDto = await _userDbHelper.Insert(options => options.WithAreaId(areaDto.Id));
      var venueDto = await _venueDbHelper.Insert(
        options => options.WithUserId(userDto.Id).WithAreaId(areaDto.Id)
      );
      return venueDto.Id;
    }

    private static string GenerateLineup(params ArtistDto[] artists) =>
      string.Join(" and ", artists.Select(a => $"<artist id=\"{a.Id}\">{a.Name}</artist>"));

    private class EventResponse : IdResponse
    {
      public string Lineup { get; set; }
      public IEnumerable<ArtistResponse> Artists { get; set; }
      public IEnumerable<ArtistResponse> ExcludedArtists { get; set; }
      public IEnumerable<RevisionResponse> Revisions { get; set; }
    }

    private class RevisionResponse : IdResponse
    {
      public EventResponse Event { get; set; }
    }

    private class ArtistResponse : IdResponse
    {
      public string Name { get; set; }
    }

    private class IdResponse
    {
      public string Id { get; set; }
    }

    [Table("tblEventsArtist")]
    private class TblEventArtist
    {
      public int EventId { get; set; }
      public int DJID { get; set; }
    }
  }
}


namespace RA.GraphQL.Integration.Tests.Helpers.Database
{
  public class EventDbHelper : BaseDbHelper
  {
    private readonly EventFaker _faker;

    public EventDbHelper(IDbConnectionFactory dbConnectionFactory)
      : base(dbConnectionFactory)
    {
      _faker = new EventFaker();
    }

    public Task<EventDto> Insert(Func<EventBuilder, EventBuilder> builderOptions)
    {
      var eventBuilder = builderOptions.Invoke(_faker.Builder());

      return DbHelper.Insert(
        _dbConnectionFactory,
        eventBuilder.Generate(),
        (messageUser, id) => messageUser.Id = id
      );
    }

    public async Task<EventDto> GetEventDto(int eventId)
    {
      var events = await DbHelper.GetAsync<EventDto>(_dbConnectionFactory, x => x.Id == eventId);
      return events.FirstOrDefault();
    }
  }
}

namespace RA.GraphQL.Integration.Tests.Fakers
{
  public class EventFaker : Faker<EventDto>
  {
    private static DateTime StartTime = new DateTime(2021, 1, 1, 22, 0, 0);
    private static DateTime EndTime = StartTime.AddHours(8);

    public EventFaker()
    {
      // Randomly Generated
      RuleFor(e => e.CountryId, f => f.Random.Byte());
      RuleFor(e => e.AreaId, f => (short)f.Random.Number());
      RuleFor(e => e.Date, f => f.Date.Soon());
      RuleFor(e => e.Title, f => f.Lorem.Sentence(4));
      RuleFor(e => e.Lineup, f => f.Lorem.Sentences());
      RuleFor(e => e.Cost, f => f.Commerce.Price());
      RuleFor(e => e.Content, f => f.Lorem.Sentences());
      RuleFor(e => e.WebsiteOneUrl, f => f.Internet.Url());
      RuleFor(e => e.WebsiteOneTitle, f => f.Company.CompanyName());
      RuleFor(e => e.FlyerFront, f => f.Internet.Url());
      RuleFor(e => e.FlyerBack, f => f.Internet.Url());
      RuleFor(e => e.DatePosted, f => f.Date.Past());
      RuleFor(e => e.TicketFeeType, f => f.Random.Enum<TicketFeeType>());

      // Static
      RuleFor(e => e.Live, true);
      RuleFor(e => e.StartTime, StartTime);
      RuleFor(e => e.EndTime, EndTime);
      RuleFor(e => e.NewEventForm, false);
      RuleFor(e => e.SubmissionSource, EventSubmissionSource.SubmitEventPage);
      RuleFor(e => e.Visibility, VisibilityType.Public);
      RuleFor(e => e.ApprovalStatus, ApprovalStatusType.Pending);

      RuleFor(e => e.TicketingSystem, TicketingSystem.Legacy);
    }

    public EventBuilder Builder()
    {
      return new EventBuilder(this);
    }
  }

  public class EventBuilder
  {
    private EventFaker _faker;
    private int _venueId;
    private int _adminUserId;
    private DateTime? _eventDate;
    private DateTime? _startTime;
    private DateTime? _endTime;
    private bool _lock;
    private byte? _minimumAge;
    private short _areaId;
    private string _cost;
    private string _content;
    private bool _newEventForm;
    private string _lineup;
    private int _parentEventId;
    private TicketFeeType? _ticketFeeTypeEnum;
    private byte _countryId;
    private DateTime? _embargoDate;
    private TicketingSystem? _ticketingSystem;

    public EventBuilder(EventFaker faker)
    {
      _faker = faker;
    }

    public EventBuilder WithVenueId(int venueId)
    {
      _venueId = venueId;
      return this;
    }

    public EventBuilder WithAdminUserId(int adminUserId)
    {
      _adminUserId = adminUserId;
      return this;
    }

    public EventBuilder WithDate(DateTime eventDate)
    {
      _eventDate = eventDate;
      return this;
    }

    public EventBuilder WithStartAndEnd(DateTime startTime, DateTime endTime)
    {
      _startTime = startTime;
      _endTime = endTime;
      return this;
    }

    public EventBuilder WithLocked(bool lockFlag)
    {
      _lock = lockFlag;
      return this;
    }

    public EventBuilder WithMinimumAge(byte? minimumAge)
    {
      _minimumAge = minimumAge;
      return this;
    }

    public EventBuilder WithCost(string cost)
    {
      _cost = cost;
      return this;
    }

    public EventBuilder WithContent(string content)
    {
      _content = content;
      return this;
    }

    public EventBuilder WithAreaId(short areaId)
    {
      _areaId = areaId;
      return this;
    }

    public EventBuilder WithNewEventFormFlag(bool newEventForm)
    {
      _newEventForm = newEventForm;
      return this;
    }

    public EventBuilder WithLineup(string lineup)
    {
      _lineup = lineup;
      return this;
    }

    public EventBuilder WithEventParentId(int parentEventId)
    {
      _parentEventId = parentEventId;
      return this;
    }

    public EventBuilder WithTicketFeeType(TicketFeeType ticketFeeTypeEnum)
    {
      _ticketFeeTypeEnum = ticketFeeTypeEnum;
      return this;
    }

    public EventBuilder WithCountryId(byte countryId)
    {
      _countryId = countryId;
      return this;
    }

    public EventBuilder WithEmbargoDate(DateTime embargoDate)
    {
      _embargoDate = embargoDate;
      return this;
    }

    public EventBuilder WithTicketingSystem(TicketingSystem ticketingSystem)
    {
      _ticketingSystem = ticketingSystem;
      return this;
    }

    public EventDto Generate()
    {
      var eventDto = _faker.Generate();

      if (_eventDate.HasValue)
        eventDto.Date = _eventDate.Value;

      if (_startTime.HasValue)
        eventDto.StartTime = _startTime.Value;

      if (_endTime.HasValue)
        eventDto.EndTime = _endTime.Value;

      if (_ticketFeeTypeEnum.HasValue)
        eventDto.TicketFeeType = _ticketFeeTypeEnum.Value;

      eventDto.AdminUserId = _adminUserId;
      eventDto.VenueId = _venueId;
      eventDto.Lock = _lock;
      eventDto.AreaId = _areaId;
      eventDto.NewEventForm = _newEventForm;
      eventDto.Lineup = _lineup;
      eventDto.CountryId = _countryId;

      if (!string.IsNullOrEmpty(_cost))
        eventDto.Cost = _cost;

      if (_parentEventId != 0)
        eventDto.ParentEventId = _parentEventId;

      if (_embargoDate.HasValue)
        eventDto.EmbargoDate = _embargoDate.Value;

      if (_ticketingSystem.HasValue)
        eventDto.TicketingSystem = _ticketingSystem.Value;

      return eventDto;
    }
  }
}

I have the EventDbHelper and EventFaker, inside the test ArtistsRemainExcludedWhenEventRevisionIsSet I would like to use these so that DatePosted is populated in the event object and my test stops failing