public async Task TestPrepareZip() { var userIds = new List <string>(); var currentAudioProcessor = new AudioProcessor(_settings); foreach (var(zipEntry, zipInputStream) in ZipUtils.GetEntries(Path.Combine("TestData", "recording.zip"))) { var temp = new byte[4096]; var ms = new MemoryStream(); StreamUtils.Copy(zipInputStream, ms, temp); ms.Position = 0; using (var bson = new BsonDataReader(ms)) { var e = new JsonSerializer().Deserialize <SerializableAudioMediaBuffer>(bson); var d = new DeserializeAudioMediaBuffer(e); var p = new DeserializeParticipant().GetParticipant(e); Assert.That((d.Data != IntPtr.Zero && e.Buffer != null) || (d.Data == IntPtr.Zero && e.Buffer == null)); Assert.AreEqual(e.IsSilence, d.IsSilence); Assert.AreEqual(e.Length, d.Length); Assert.AreEqual(e.Timestamp, d.Timestamp); Assert.AreEqual(e.ActiveSpeakers, d.ActiveSpeakers); Assert.AreEqual(e.SerializableUnmixedAudioBuffers?.Length, d.UnmixedAudioBuffers?.Length); if (d.Data != IntPtr.Zero && e.Buffer != null) { var buffer = new byte[d.Length]; Marshal.Copy(d.Data, buffer, 0, (int)d.Length); Assert.AreEqual(e.Buffer, buffer); } for (int i = 0; i < e.SerializableUnmixedAudioBuffers?.Length; i++) { Assert.AreEqual(e.SerializableUnmixedAudioBuffers.Length, d.UnmixedAudioBuffers.Length); Assert.AreEqual(e.SerializableUnmixedAudioBuffers.Length, p.Count); var source = e.SerializableUnmixedAudioBuffers[i]; var actual = d.UnmixedAudioBuffers[i]; var participant = p[i].Resource.Info.Identity.User; Assert.AreEqual(source.ActiveSpeakerId, actual.ActiveSpeakerId); Assert.AreEqual(source.Length, actual.Length); Assert.AreEqual(source.OriginalSenderTimestamp, actual.OriginalSenderTimestamp); var buffer = new byte[actual.Length]; Marshal.Copy(actual.Data, buffer, 0, (int)actual.Length); Assert.AreEqual(source.Buffer, buffer); Assert.AreEqual(source.DisplayName, participant.DisplayName); Assert.AreEqual(source.AdditionalData, participant.AdditionalData); Assert.AreEqual(source.AdId, participant.Id); Assert.That(p[i].Resource.MediaStreams.Any(x => x.SourceId == source.ActiveSpeakerId.ToString())); Assert.IsFalse(p[i].Resource.IsInLobby); if (!userIds.Contains(source.AdId) && source.AdId != null) { userIds.Add(source.AdId); } } await currentAudioProcessor.Append(e); } } var lastZip = await currentAudioProcessor.Finalise(); var lastFileInfo = new FileInfo(lastZip); var fileNames = getfileNames(lastZip).ToList(); foreach (var userId in userIds) { var match = fileNames.FirstOrDefault(_ => _.Contains(userId)); Assert.NotNull(match); } lastFileInfo.Directory?.Delete(true); }