public async Task Should_not_remove_heartbeats_for_conferences_within_14_days() { _conferenceList = new List <Conference>(); var utcDate = DateTime.UtcNow; var hearingWithin14Days = utcDate.AddDays(-13); var conference1 = new ConferenceBuilder(true, scheduledDateTime: hearingWithin14Days) .WithParticipant(UserRole.Representative, "Respondent") .WithParticipant(UserRole.Judge, null) .WithConferenceStatus(ConferenceState.Closed) .Build(); _conference1Id = conference1.Id; var participantId = conference1.GetParticipants().First().Id; _conferenceList.Add(conference1); foreach (var c in _conferenceList) { await TestDataManager.SeedConference(c); } var command = new SaveHeartbeatCommand(_conference1Id, participantId, 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, participantId, 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); command = new SaveHeartbeatCommand(_conference1Id, participantId, 0.30M, 0.15M, 0.60M, 1.50M, 0.00M, 0.00M, 0.80M, 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(3); }
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); }
public async Task <IActionResult> SaveHeartbeatDataForParticipantAsync(Guid conferenceId, Guid participantId, AddHeartbeatRequest request) { _logger.LogDebug("SaveHeartbeatDataForParticipantAsync"); if (request == null) { _logger.LogWarning("AddHeartbeatRequest is null"); return(BadRequest()); } var command = new SaveHeartbeatCommand ( conferenceId, participantId, request.OutgoingAudioPercentageLost, request.OutgoingAudioPercentageLostRecent, request.IncomingAudioPercentageLost, request.IncomingAudioPercentageLostRecent, request.OutgoingVideoPercentageLost, request.OutgoingVideoPercentageLostRecent, request.IncomingVideoPercentageLost, request.IncomingVideoPercentageLostRecent, DateTime.UtcNow, request.BrowserName, request.BrowserVersion, request.OperatingSystem, request.OperatingSystemVersion ); await _commandHandler.Handle(command); return(NoContent()); }