-
Notifications
You must be signed in to change notification settings - Fork 396
/
Copy pathClockExtensionTests.cs
72 lines (60 loc) · 1.92 KB
/
ClockExtensionTests.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
67
68
69
70
71
72
// 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.Threading.Tasks;
using ClockExtension;
using FluentAssertions;
using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.CSharp;
using Microsoft.DotNet.Interactive.Events;
using Microsoft.DotNet.Interactive.Tests.Utility;
using Xunit;
namespace SampleExtensions.Tests
{
public class ClockExtensionTests : IDisposable
{
private readonly Kernel _kernel;
public ClockExtensionTests()
{
_kernel = new CompositeKernel
{
new CSharpKernel()
};
ClockKernelExtension.Load(_kernel);
}
public void Dispose()
{
_kernel.Dispose();
}
[Fact]
public async Task It_formats_DateTime()
{
var result = await _kernel.SubmitCodeAsync("DateTime.Now");
AssertThatClockWasRendered(result);
}
[Fact]
public async Task It_formats_DateTimeOffset()
{
var result = await _kernel.SubmitCodeAsync("DateTimeOffset.Now");
AssertThatClockWasRendered(result);
}
[Fact]
public async Task It_adds_a_clock_magic_command()
{
var result = await _kernel.SubmitCodeAsync("#!clock");
AssertThatClockWasRendered(result);
}
private void AssertThatClockWasRendered(KernelCommandResult result) =>
result.Events
.Should()
.ContainSingle<DisplayEvent>()
.Which
.FormattedValues
.Should()
.ContainSingle(v => v.MimeType == "text/html")
.Which
.Value
.Should()
.Contain("<circle");
}
}