-
Notifications
You must be signed in to change notification settings - Fork 368
/
TranscriptTests.cs
47 lines (35 loc) · 1.4 KB
/
TranscriptTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using FluentAssertions;
using System.Linq;
using System.Reactive.Disposables;
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.FSharp;
using Microsoft.DotNet.Interactive.Tests.Utility;
using Xunit;
namespace Microsoft.DotNet.Interactive.ExtensionLab.Tests;
public class TranscriptTests : IDisposable
{
private readonly CompositeDisposable _disposables = new CompositeDisposable();
[Fact]
public async Task transcript_extension_writes_all_received_commands_to_the_specified_file()
{
var kernel = new CompositeKernel
{
new FSharpKernel()
};
await new RecordTranscriptExtension().OnLoadAsync(kernel);
var filePath = Path.Combine(
Directory.GetCurrentDirectory(),
Guid.NewGuid().ToString());
_disposables.Add(Disposable.Create(() => File.Delete(filePath)));
using var events = kernel.KernelEvents.ToSubscribedList();
await kernel.SubmitCodeAsync($"#!record --output {filePath}");
await kernel.SubmitCodeAsync("12345");
var lines = File.ReadAllLines(filePath);
lines.First().Should().Contain("12345");
}
public void Dispose() => _disposables.Dispose();
}