-
Notifications
You must be signed in to change notification settings - Fork 367
/
DataExplorerTests.cs
66 lines (55 loc) · 2.12 KB
/
DataExplorerTests.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
55
56
57
58
59
60
61
62
63
64
65
66
// 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 FluentAssertions;
using Microsoft.AspNetCore.Html;
using Xunit;
namespace Microsoft.DotNet.Interactive.Tests
{
public class DataExplorerTests
{
[Fact]
public void when_there_is_single_DataExplorer_return_it_as_default()
{
DataExplorer<string>.Register<StringDataExplorer>();
var dataExplorer = DataExplorer.CreateDefault("hello world");
dataExplorer.Should().BeOfType<StringDataExplorer>();
}
[Fact]
public void can_create_specific_DataExplorer_for_a_data_type()
{
DataExplorer<string>.Register<StringDataExplorer>();
DataExplorer<string>.Register<AdvancedStringDataExplorer>();
var dataExplorer = DataExplorer.Create("AdvancedStringDataExplorer", "hello world");
dataExplorer.Should().BeOfType<AdvancedStringDataExplorer>();
}
[Fact]
public void can_specify_default_DataExplorer_for_a_data_type()
{
DataExplorer<string>.Register<StringDataExplorer>();
DataExplorer<string>.Register<AdvancedStringDataExplorer>();
DataExplorer.SetDefault<string, AdvancedStringDataExplorer>();
var dataExplorer = DataExplorer.CreateDefault("hello world");
dataExplorer.Should().BeOfType<AdvancedStringDataExplorer>();
}
private class StringDataExplorer : DataExplorer<string>
{
public StringDataExplorer(string data) : base(data)
{
}
protected override IHtmlContent ToHtml()
{
return new HtmlString(Data);
}
}
private class AdvancedStringDataExplorer : DataExplorer<string>
{
public AdvancedStringDataExplorer(string data) : base(data)
{
}
protected override IHtmlContent ToHtml()
{
return new HtmlString(Data);
}
}
}
}