mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 18:07:21 +00:00
Upgraded to .NET 10 (#1147)
This commit is contained in:
1 parent
faae2951f7
commit
fc7399e81b
327 files changed
+3059
-3049
No files matched your search
@@ -42,11 +42,11 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
var mediaPath = await this.CreateMediaAsync("recording.mp3", [1, 2, 3]);
|
||||
var slot = await this.Store().ResolveAsync(mediaPath, CancellationToken.None);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(DataSourceTranscriptStore.IsKey(slot.Key), Is.True);
|
||||
Assert.That(slot.Path, Is.EqualTo(Path.Join(this.dataDirectory, DataSourceTranscriptStore.FOLDER_NAME, DATA_SOURCE_ID, slot.Key + ".md")));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -62,11 +62,11 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
var copySlot = await store.ResolveAsync(copy, CancellationToken.None);
|
||||
var otherSlot = await store.ResolveAsync(other, CancellationToken.None);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(copySlot, Is.EqualTo(originalSlot));
|
||||
Assert.That(otherSlot.Key, Is.Not.EqualTo(originalSlot.Key));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -81,12 +81,12 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
var slotWhileUnchanged = await store.WithKnownContentHash(unrelatedHash, _ => true).ResolveAsync(mediaPath, CancellationToken.None);
|
||||
var slotOnceChanged = await store.WithKnownContentHash(unrelatedHash, _ => false).ResolveAsync(mediaPath, CancellationToken.None);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(slotWhileUnchanged.Key, Is.EqualTo(unrelatedHash), "Hashing a video reads all of it, which the indexer did already.");
|
||||
Assert.That(slotWhileUnchanged.Path, Is.EqualTo(store.GetPath(unrelatedHash)));
|
||||
Assert.That(slotOnceChanged.Key, Is.EqualTo(knownHash), "A file which changed since it was hashed must not get the transcript of its content before.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -108,14 +108,14 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
File.SetLastWriteTimeUtc(renamedPath, DateTime.UtcNow.AddMinutes(5));
|
||||
var second = await PersistentMediaTranscript.ReadOrCreateAsync(this.Store(), renamedPath, provider, Transcribe, NullLogger.Instance, CancellationToken.None);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(first.Status, Is.EqualTo(PersistentMediaTranscriptStatus.READY));
|
||||
Assert.That(second.Status, Is.EqualTo(PersistentMediaTranscriptStatus.READY));
|
||||
Assert.That(second.Reused, Is.True);
|
||||
Assert.That(calls, Is.EqualTo(1));
|
||||
Assert.That(Directory.GetFiles(this.userFolder), Has.Length.EqualTo(1), "The data source wrote into the folder of the user.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -134,12 +134,12 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
|
||||
store.DeleteAll();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(File.Exists(transcriptPath), Is.False);
|
||||
Assert.That(Directory.GetFiles(folder, "*.tmp"), Is.Empty);
|
||||
Assert.That(File.Exists(Path.Combine(folder, "notes.md")), Is.True, "A file which the store did not write was deleted.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -183,11 +183,11 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
var deleted = store.Delete(key);
|
||||
store.DeleteAll();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(deleted, Is.False);
|
||||
Assert.That(File.ReadAllText(targetPath), Is.EqualTo("Precious"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -208,7 +208,7 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
var copied = await DataSourceTranscriptStore.CopyAllAsync(this.dataDirectory, targetDirectory, CancellationToken.None);
|
||||
|
||||
var copiedFiles = Directory.GetFiles(targetDirectory, "*", SearchOption.AllDirectories).Select(path => Path.GetRelativePath(targetDirectory, path).Replace('\\', '/'));
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(copied, Is.EqualTo(2));
|
||||
Assert.That(copiedFiles, Is.EquivalentTo(new[]
|
||||
@@ -216,7 +216,7 @@ public sealed class DataSourceTranscriptStoreTests
|
||||
$"{DataSourceTranscriptStore.FOLDER_NAME}/{DATA_SOURCE_ID}/{new string('d', 64)}.md",
|
||||
$"{DataSourceTranscriptStore.FOLDER_NAME}/{secondId}/{new string('e', 64)}.md",
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -43,12 +43,12 @@ public sealed class PersistentMediaTranscriptTests
|
||||
|
||||
var result = await this.ReadOrCreateAsync(transcriber, this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.READY));
|
||||
Assert.That(result.Reused, Is.True);
|
||||
Assert.That(transcriber.Calls, Is.Zero);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -66,11 +66,11 @@ public sealed class PersistentMediaTranscriptTests
|
||||
|
||||
var result = await this.ReadOrCreateAsync(transcriber, null);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.NO_PROVIDER));
|
||||
Assert.That(transcriber.Calls, Is.Zero);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -81,7 +81,7 @@ public sealed class PersistentMediaTranscriptTests
|
||||
var first = await this.ReadOrCreateAsync(transcriber, this.provider);
|
||||
var second = await this.ReadOrCreateAsync(transcriber, this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(first.Status, Is.EqualTo(PersistentMediaTranscriptStatus.READY));
|
||||
Assert.That(first.Reused, Is.False);
|
||||
@@ -89,7 +89,7 @@ public sealed class PersistentMediaTranscriptTests
|
||||
Assert.That(second.Reused, Is.True);
|
||||
Assert.That(transcriber.Calls, Is.EqualTo(1));
|
||||
Assert.That(Directory.GetFiles(this.directoryPath, "*.tmp"), Is.Empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -97,11 +97,11 @@ public sealed class PersistentMediaTranscriptTests
|
||||
{
|
||||
var result = await this.ReadOrCreateAsync(new CountingTranscriber(() => MediaTranscriptionResult.Succeeded(" \n ")), this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.EMPTY));
|
||||
Assert.That(File.Exists(MediaSidecarTranscripts.GetFilePath(this.mediaPath)), Is.False);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -112,12 +112,12 @@ public sealed class PersistentMediaTranscriptTests
|
||||
|
||||
var result = await this.ReadOrCreateAsync(transcriber, this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.READY));
|
||||
Assert.That(transcriber.Calls, Is.EqualTo(1));
|
||||
Assert.That(File.ReadAllText(result.TranscriptPath), Is.EqualTo("Transcript"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -131,11 +131,11 @@ public sealed class PersistentMediaTranscriptTests
|
||||
|
||||
var result = await this.ReadOrCreateAsync(transcriber, this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.SOURCE_CHANGED));
|
||||
Assert.That(File.Exists(MediaSidecarTranscripts.GetFilePath(this.mediaPath)), Is.False);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -146,11 +146,11 @@ public sealed class PersistentMediaTranscriptTests
|
||||
|
||||
var result = await PersistentMediaTranscript.ReadOrCreateAsync(MediaSidecarTranscripts.INSTANCE, this.mediaPath, this.provider, transcriber.TranscribeAsync, NullLogger.Instance, cancellation.Token);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.READY));
|
||||
Assert.That(File.ReadAllText(MediaSidecarTranscripts.GetFilePath(this.mediaPath)), Is.EqualTo("Paid transcript"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -158,11 +158,11 @@ public sealed class PersistentMediaTranscriptTests
|
||||
{
|
||||
var result = await this.ReadOrCreateAsync(new CountingTranscriber(MediaTranscriptionResult.Cancelled), this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.CANCELLED));
|
||||
Assert.That(File.Exists(MediaSidecarTranscripts.GetFilePath(this.mediaPath)), Is.False);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -170,12 +170,12 @@ public sealed class PersistentMediaTranscriptTests
|
||||
{
|
||||
var result = await this.ReadOrCreateAsync(new CountingTranscriber(() => MediaTranscriptionResult.Failed("The container is damaged.", MediaJobErrorCode.DAMAGED_CONTAINER)), this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.TRANSCRIPTION_FAILED));
|
||||
Assert.That(result.ErrorCode, Is.EqualTo(MediaJobErrorCode.DAMAGED_CONTAINER));
|
||||
Assert.That(result.UserMessage, Is.EqualTo("The container is damaged."));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -183,12 +183,12 @@ public sealed class PersistentMediaTranscriptTests
|
||||
{
|
||||
var result = await this.ReadOrCreateAsync(new CountingTranscriber(() => MediaTranscriptionResult.Rejected("The file is too large.")), this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.REJECTED));
|
||||
Assert.That(result.UserMessage, Is.EqualTo("The file is too large."));
|
||||
Assert.That(File.Exists(MediaSidecarTranscripts.GetFilePath(this.mediaPath)), Is.False);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -204,11 +204,11 @@ public sealed class PersistentMediaTranscriptTests
|
||||
|
||||
var result = await PersistentMediaTranscript.ReadOrCreateAsync(location, this.mediaPath, this.provider, new CountingTranscriber(() => MediaTranscriptionResult.Succeeded("Transcript")).TranscribeAsync, NullLogger.Instance, CancellationToken.None);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.STORE_FAILED));
|
||||
Assert.That(Directory.GetFiles(this.directoryPath, "*.tmp", SearchOption.AllDirectories), Is.Empty);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -219,11 +219,11 @@ public sealed class PersistentMediaTranscriptTests
|
||||
|
||||
var result = await this.ReadOrCreateAsync(transcriber, this.provider);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(result.Status, Is.EqualTo(PersistentMediaTranscriptStatus.SOURCE_UNREADABLE));
|
||||
Assert.That(transcriber.Calls, Is.Zero);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Task<PersistentMediaTranscriptResult> ReadOrCreateAsync(CountingTranscriber transcriber, TranscriptionProvider? transcriptionProvider) => PersistentMediaTranscript.ReadOrCreateAsync(MediaSidecarTranscripts.INSTANCE, this.mediaPath, transcriptionProvider, transcriber.TranscribeAsync, NullLogger.Instance, CancellationToken.None);
|
||||
|
||||
@@ -82,11 +82,11 @@ public sealed class TranscriptCleanupTests
|
||||
|
||||
FileSourceIndexer.DeleteUnusedTranscripts(this.store, manifest, NullLogger.Instance);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(this.store.ListKeys(), Is.EqualTo(new[] { KEY_A }));
|
||||
Assert.That(File.Exists(temporaryPath), Is.False, "A temporary file of an interrupted write is no transcript of anything.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -78,12 +78,12 @@ public sealed class TranscriptPromptInjectionTests
|
||||
|
||||
var extraction = await PersistentMediaTranscript.ReadTranscriptAsync(this.rustService, transcript, this.mediaPath, reportingScope: null, CancellationToken.None);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(this.runtime.ReadFiles, Is.EqualTo(new[] { transcript.TranscriptPath }), "The transcript did not go through the runtime, or the runtime was asked for the recording instead.");
|
||||
Assert.That(extraction.Content, Does.Not.Contain(SUSPICIOUS_PASSAGE), "The suspicious passage reached the AI.");
|
||||
Assert.That(extraction.Content, Does.Contain("Welcome to the meeting.").And.Contain(FakeRuntime.REDACTION_MARKER), "The rest of the transcript got lost.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -97,11 +97,11 @@ public sealed class TranscriptPromptInjectionTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OnlyAReadyTranscriptCanBeRead()
|
||||
public async Task OnlyAReadyTranscriptCanBeRead()
|
||||
{
|
||||
var transcript = PersistentMediaTranscriptResult.Unavailable(PersistentMediaTranscriptStatus.NO_PROVIDER, null, "No provider.");
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(() => PersistentMediaTranscript.ReadTranscriptAsync(this.rustService, transcript, this.mediaPath, reportingScope: null, CancellationToken.None));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => PersistentMediaTranscript.ReadTranscriptAsync(this.rustService, transcript, this.mediaPath, reportingScope: null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -113,12 +113,12 @@ public sealed class TranscriptPromptInjectionTests
|
||||
await service.AddCompletedTextAsync(target, this.mediaPath, $"Welcome to the meeting. {SUSPICIOUS_PASSAGE} Let us begin.");
|
||||
var delivered = service.GetPendingDelivery(target)?.Text;
|
||||
|
||||
Assert.Multiple(() =>
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(this.runtime.FilteredTexts, Has.Count.EqualTo(1), "The transcript did not go through the filter.");
|
||||
Assert.That(delivered, Does.Not.Contain(SUSPICIOUS_PASSAGE), "The suspicious passage reached the field, and with it the AI.");
|
||||
Assert.That(delivered, Does.Contain("Welcome to the meeting.").And.Contain(FakeRuntime.REDACTION_MARKER), "The rest of the transcript got lost.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user