using Xunit; using leak_test_project.Utils; using leak_test_project.Models; namespace leak_test_project.Tests.Utils { public class SentinelParserTests { [Theory] [InlineData("AABB010\tH\tLR 0.123456 sccm", 'H', "LR 0.123456 sccm")] [InlineData("AABB010 H LR 0.123456 sccm", 'H', "LR 0.123456 sccm")] public void ExtractBody_ValidInput_ShouldExtractCorrectBodyAndTypeCode(string input, char expectedType, string expectedBody) { // Act string resultBody = SentinelParser.ExtractBody(input, out char resultType); // Assert Assert.Equal(expectedType, resultType); Assert.Equal(expectedBody, resultBody); } [Fact] public void ParseStreamingValue_ValidInput_ShouldParseValueAndUnit() { // Arrange string input = "AABB010\tH\tLR 0.123456 sccm"; // Act ParsedData result = SentinelParser.ParseStreamingValue(input); // Assert Assert.Equal(0.123456, result.MeasuredValue); Assert.Equal("sccm", result.Unit); } [Fact] public void ParseFinalResult_ValidInput_ShouldParseAllFields() { // Arrange // Sample based on manual: XXYYZZZ \t H \t C## \t P## \t LL \t HH:MM:SS \t MM/DD/YY \t ID \t Eval ... // We need a proper string that matches the tab-separated structure. string body = "C01\tPort1\tP05\tLink\t12:30:45\t03/26/24\t1234567890\tA\tFlag\tTest\tEval\tLR 0.5 sccm"; string input = "XXXXYYY\tH\t" + body; // Act ParsedData result = SentinelParser.ParseFinalResult(input); // Assert Assert.Equal("C01", result.ChannelNo); Assert.Equal("P05", result.ProgramNo); Assert.Equal("OK", result.Judgment); // A -> OK Assert.Equal(0.5, result.MeasuredValue); Assert.Equal("sccm", result.Unit); } [Theory] [InlineData(5.0, 10.0, 1.0, "OK")] [InlineData(15.0, 10.0, 1.0, "NG")] [InlineData(0.5, 10.0, 1.0, "NG")] public void EvaluateJudgment_ShouldReturnCorrectStatus(double value, double ul, double ll, string expected) { // Act var result = SentinelParser.EvaluateJudgment(value, ul, ll); // Assert Assert.Equal(expected, result); } } }