-
Notifications
You must be signed in to change notification settings - Fork 367
/
DataFrameKernelExtensionTests.cs
54 lines (39 loc) · 1.36 KB
/
DataFrameKernelExtensionTests.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
48
49
50
51
52
53
54
// 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.Diagnostics;
using System.Threading.Tasks;
using Assent;
using Microsoft.Data.Analysis;
using Microsoft.DotNet.Interactive.Formatting;
using Microsoft.DotNet.Interactive.Formatting.TabularData;
using Xunit;
namespace Microsoft.DotNet.Interactive.ExtensionLab.Tests;
public class DataFrameKernelExtensionTests : IDisposable
{
private readonly Configuration _configuration;
public DataFrameKernelExtensionTests()
{
_configuration = new Configuration()
.SetInteractive(Debugger.IsAttached)
.UsingExtension("json");
}
[Fact]
public async Task it_registers_formatters()
{
using var kernel = new CompositeKernel();
var kernelExtension = new DataFrameKernelExtension();
await kernelExtension.OnLoadAsync(kernel);
var stream = @"id,name,color,deliciousness
1,apple,green,10
2,banana,yellow,11
3,cherry,red,9000";
var dataFrame = DataFrame.LoadCsvFromString(stream);
var formatted = dataFrame.ToDisplayString(TabularDataResourceFormatter.MimeType);
this.Assent(formatted, _configuration);
}
public void Dispose()
{
Formatter.ResetToDefault();
}
}