-
Notifications
You must be signed in to change notification settings - Fork 368
/
KernelExtensionsTests.cs
74 lines (61 loc) · 2.15 KB
/
KernelExtensionsTests.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
73
74
// 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.DotNet.Interactive.Tests.Utility;
using Xunit;
namespace Microsoft.DotNet.Interactive.Tests
{
public class KernelExtensionsTests
{
[Fact]
public void FindKernelByName_finds_a_subkernel_of_a_composite_kernel_by_name()
{
var one = new FakeKernel("one");
var two = new FakeKernel("two");
using var compositeKernel = new CompositeKernel
{
one,
two,
};
var found = compositeKernel.FindKernelByName("two");
found.Should().BeSameAs(two);
}
[Fact]
public void FindKernelByName_finds_a_subkernel_of_a_composite_kernel_by_alias()
{
var one = new FakeKernel("one");
var two = new FakeKernel("two");
using var compositeKernel = new CompositeKernel();
compositeKernel.Add(one, aliases: new[] { "one-alias" });
compositeKernel.Add(two);
var found = compositeKernel.FindKernelByName("one-alias");
found.Should().BeSameAs(one);
}
[Fact]
public void FindKernelByName_finds_a_subkernel_of_a_parent_composite_kernel_by_name()
{
var one = new FakeKernel("one");
var two = new FakeKernel("two");
using var compositeKernel = new CompositeKernel
{
one,
two,
};
var found = one.FindKernelByName("two");
found.Should().BeSameAs(two);
}
[Fact]
public void FindKernelByName_returns_null_for_unknown_kernel()
{
var one = new FakeKernel("one");
var two = new FakeKernel("two");
using var compositeKernel = new CompositeKernel
{
one,
two,
};
var found = compositeKernel.FindKernelByName("three");
found.Should().BeNull();
}
}
}