-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWildcardMatchAnalyzerTests.cs
More file actions
131 lines (107 loc) · 3.99 KB
/
WildcardMatchAnalyzerTests.cs
File metadata and controls
131 lines (107 loc) · 3.99 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace IntelliTect.TestTools.Console.Tests;
[TestClass]
public class WildcardMatchAnalyzerTests
{
[TestMethod]
public void AnalyzeMatch_SingleLineMatch_IdentifiesWildcardMatches()
{
// Arrange
string expected = "Hello * world";
string actual = "Hello beautiful world";
// Act
var results = WildcardMatchAnalyzer.AnalyzeMatch(expected, actual);
// Assert
Assert.AreEqual(1, results.Count);
Assert.IsTrue(results[0].IsMatch);
Assert.AreEqual(1, results[0].WildcardMatches.Count);
// The * matches "beautiful" (without trailing space because "world" comes next)
Assert.AreEqual("beautiful", results[0].WildcardMatches[0].MatchedText);
}
[TestMethod]
public void AnalyzeMatch_MultipleWildcards_TracksAllMatches()
{
// Arrange
string expected = "PING *(* (::1)) * data bytes";
string actual = "PING localhost(localhost (::1)) 56 data bytes";
// Act
var results = WildcardMatchAnalyzer.AnalyzeMatch(expected, actual);
// Assert
Assert.AreEqual(1, results.Count);
Assert.IsTrue(results[0].IsMatch);
Assert.IsTrue(results[0].WildcardMatches.Count >= 2);
}
[TestMethod]
public void AnalyzeMatch_Mismatch_IdentifiesFailure()
{
// Arrange
string expected = "Hello world";
string actual = "Hello universe";
// Act
var results = WildcardMatchAnalyzer.AnalyzeMatch(expected, actual);
// Assert
Assert.AreEqual(1, results.Count);
Assert.IsFalse(results[0].IsMatch);
}
[TestMethod]
public void AnalyzeMatch_ExtraLinesInActual_MarkedAsUnexpected()
{
// Arrange
string expected = "Line 1\nLine 2";
string actual = "Line 1\nLine 2\nLine 3";
// Act
var results = WildcardMatchAnalyzer.AnalyzeMatch(expected, actual);
// Assert
Assert.AreEqual(3, results.Count);
Assert.IsTrue(results[0].IsMatch);
Assert.IsTrue(results[1].IsMatch);
Assert.IsFalse(results[2].IsMatch); // Extra line
Assert.IsNull(results[2].ExpectedLine);
Assert.IsNotNull(results[2].ActualLine);
}
[TestMethod]
public void AnalyzeMatch_MissingLinesInActual_MarkedAsMissing()
{
// Arrange
string expected = "Line 1\nLine 2\nLine 3";
string actual = "Line 1\nLine 2";
// Act
var results = WildcardMatchAnalyzer.AnalyzeMatch(expected, actual);
// Assert
Assert.AreEqual(3, results.Count);
Assert.IsTrue(results[0].IsMatch);
Assert.IsTrue(results[1].IsMatch);
Assert.IsFalse(results[2].IsMatch); // Missing line
Assert.IsNotNull(results[2].ExpectedLine);
Assert.IsNull(results[2].ActualLine);
}
[TestMethod]
public void GenerateDetailedDiff_CreatesReadableOutput()
{
// Arrange
string expected = "Hello * world\nLine *";
string actual = "Hello beautiful world\nLine 2";
var results = WildcardMatchAnalyzer.AnalyzeMatch(expected, actual);
// Act
string diff = WildcardMatchAnalyzer.GenerateDetailedDiff(results);
// Assert
Assert.IsFalse(string.IsNullOrEmpty(diff));
StringAssert.Contains(diff, "Line-by-line comparison");
StringAssert.Contains(diff, "✅"); // Should contain success markers
StringAssert.Contains(diff, "Wildcard matches");
}
[TestMethod]
public void GenerateDetailedDiff_WithMismatch_ShowsFailure()
{
// Arrange
string expected = "Expected text";
string actual = "Actual text";
var results = WildcardMatchAnalyzer.AnalyzeMatch(expected, actual);
// Act
string diff = WildcardMatchAnalyzer.GenerateDetailedDiff(results);
// Assert
Assert.IsFalse(string.IsNullOrEmpty(diff));
StringAssert.Contains(diff, "❌"); // Should contain failure marker
}
}