Skip to content

Commit af1f30a

Browse files
added ut for the telemetry
1 parent ab882b4 commit af1f30a

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

src/Telemetry.UTest/Telemetry.UTest.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,60 @@ public void Constructor_ShouldThrowException_ForInvalidTelemetryType()
9090
{
9191
Assert.Throws<NotSupportedException>(() => new LCT.Telemetry.Telemetry("InvalidType", configuration));
9292
}
93+
[Test]
94+
public void GetHashString_InputIsNull_ReturnsEmptyString()
95+
{
96+
// Arrange
97+
string input = null;
98+
99+
// Act
100+
string result = HashUtility.GetHashString(input);
101+
102+
// Assert
103+
Assert.AreEqual(string.Empty, result);
104+
}
105+
106+
[Test]
107+
public void GetHashString_InputIsEmpty_ReturnsEmptyString()
108+
{
109+
// Arrange
110+
string input = string.Empty;
111+
112+
// Act
113+
string result = HashUtility.GetHashString(input);
114+
115+
// Assert
116+
Assert.AreEqual(string.Empty, result);
117+
}
93118

119+
[Test]
120+
public void GetHashString_ValidInput_ReturnsExpectedHash()
121+
{
122+
// Arrange
123+
string input = "test";
124+
string expectedHash = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"; // Precomputed SHA256 hash for "test"
125+
126+
// Act
127+
string result = HashUtility.GetHashString(input);
128+
129+
// Assert
130+
Assert.AreEqual(expectedHash, result);
131+
}
132+
133+
[Test]
134+
public void GetHashString_DifferentInputs_ReturnDifferentHashes()
135+
{
136+
// Arrange
137+
string input1 = "test1";
138+
string input2 = "test2";
139+
140+
// Act
141+
string result1 = HashUtility.GetHashString(input1);
142+
string result2 = HashUtility.GetHashString(input2);
143+
144+
// Assert
145+
Assert.AreNotEqual(result1, result2);
146+
}
94147

95148
}
96149
}

0 commit comments

Comments
 (0)