public async Task Should_remove_heartbeats_for_conferences_older_than_14_days()
        {
            _conferenceList = new List <Conference>();
            var utcDate = DateTime.UtcNow;
            var hearingOlderThan14Days = utcDate.AddDays(-14);

            var conference1 = new ConferenceBuilder(true, scheduledDateTime: hearingOlderThan14Days)
                              .WithParticipant(UserRole.Representative, "Respondent")
                              .WithParticipant(UserRole.Judge, null)
                              .WithConferenceStatus(ConferenceState.Closed)
                              .Build();

            _conference1Id = conference1.Id;
            var conference1ParticipantId = conference1.GetParticipants().First().Id;

            _conferenceList.Add(conference1);

            foreach (var c in _conferenceList)
            {
                await TestDataManager.SeedConference(c);
            }

            var command = new SaveHeartbeatCommand(_conference1Id, conference1ParticipantId, 0.00M, 0.00M, 0.40M, 0.10M,
                                                   0.00M, 0.00M, 0.50M, 0.20M, DateTime.UtcNow, "Chrome", "84.0.4147.105", "Mac OS X", "10.15.7");
            await _saveHeartbeatHandler.Handle(command);

            command = new SaveHeartbeatCommand(_conference1Id, conference1ParticipantId, 0.00M, 0.00M, 0.50M, 1.50M,
                                               0.00M, 0.00M, 0.50M, 1.50M, DateTime.UtcNow, "Chrome", "84.0.4147.105", "Mac OS X", "10.15.7");
            await _saveHeartbeatHandler.Handle(command);

            var removeCommand = new RemoveHeartbeatsForConferencesCommand();
            await _handler.Handle(removeCommand);

            List <Heartbeat> heartbeats;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                heartbeats = await db.Heartbeats.Where(x => x.ConferenceId == _conference1Id).ToListAsync();
            }

            var afterCount = heartbeats.Count;

            afterCount.Should().Be(0);
        }
        public async Task Should_save_heartbeats()
        {
            var seededConference = await TestDataManager.SeedConference();

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;
            var participantId = seededConference.GetParticipants().First().Id;

            var command = new SaveHeartbeatCommand(_newConferenceId, participantId, 1, 1, 1, 1, 1, 1, 1, 1,
                                                   DateTime.UtcNow, "chrome", "1", "Mac OS X", "10.15.7");
            await _handler.Handle(command);

            Heartbeat savedHeartbeat;

            await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions))
            {
                savedHeartbeat = await db.Heartbeats.FirstOrDefaultAsync(x =>
                                                                         x.ConferenceId == _newConferenceId && x.ParticipantId == participantId);
            }

            savedHeartbeat.Should().NotBeNull();
            savedHeartbeat.ConferenceId.Should().Be(_newConferenceId);
            savedHeartbeat.ParticipantId.Should().Be(participantId);
            savedHeartbeat.OutgoingAudioPercentageLost.Should().Be(1);
            savedHeartbeat.OutgoingAudioPercentageLostRecent.Should().Be(1);
            savedHeartbeat.IncomingAudioPercentageLost.Should().Be(1);
            savedHeartbeat.IncomingAudioPercentageLostRecent.Should().Be(1);
            savedHeartbeat.OutgoingVideoPercentageLost.Should().Be(1);
            savedHeartbeat.OutgoingVideoPercentageLostRecent.Should().Be(1);
            savedHeartbeat.IncomingVideoPercentageLost.Should().Be(1);
            savedHeartbeat.IncomingVideoPercentageLostRecent.Should().Be(1);
            savedHeartbeat.BrowserName.Should().Be("chrome");
            savedHeartbeat.BrowserVersion.Should().Be("1");
            savedHeartbeat.Timestamp.Should().NotBe(new DateTime());
            savedHeartbeat.Timestamp.Should().BeAfter(DateTime.MinValue);
            savedHeartbeat.Timestamp.Should().BeBefore(DateTime.MaxValue);
        }