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
75
76
77
78
79
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace Microsoft.AspNetCore.Routing.Matching;
public abstract class MultipleEntryJumpTableTest
{
internal abstract JumpTable CreateTable(
int defaultDestination,
int exitDestination,
params (string text, int destination)[] entries);
[Fact]
public void GetDestination_ZeroLengthSegment_JumpsToExit()
{
// Arrange
var table = CreateTable(0, 1, ("text", 2));
// Act
var result = table.GetDestination("ignored", new PathSegment(0, 0));
// Assert
Assert.Equal(1, result);
}
[Fact]
public void GetDestination_NonMatchingSegment_JumpsToDefault()
{
// Arrange
var table = CreateTable(0, 1, ("text", 2));
// Act
var result = table.GetDestination("text", new PathSegment(1, 2));
// Assert
Assert.Equal(0, result);
}
[Fact]
public void GetDestination_SegmentMatchingText_JumpsToDestination()
{
// Arrange
var table = CreateTable(0, 1, ("text", 2));
// Act
var result = table.GetDestination("some-text", new PathSegment(5, 4));
// Assert
Assert.Equal(2, result);
}
[Fact]
public void GetDestination_SegmentMatchingTextIgnoreCase_JumpsToDestination()
{
// Arrange
var table = CreateTable(0, 1, ("text", 2));
// Act
var result = table.GetDestination("some-tExt", new PathSegment(5, 4));
// Assert
Assert.Equal(2, result);
}
[Fact]
public void GetDestination_SegmentMatchingTextIgnoreCase_MultipleEntries()
{
// Arrange
var table = CreateTable(0, 1, ("tezt", 2), ("text", 3));
// Act
var result = table.GetDestination("some-tExt", new PathSegment(5, 4));
// Assert
Assert.Equal(3, result);
}
}
|