|
|
|
|
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_ValidHeaderInput_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 ExtractBody_AutoResult_NoHeader_ShouldReturnResultType()
|
|
|
|
|
{
|
|
|
|
|
// Arrange (C28 매뉴얼 표 규격: 헤더 없이 탭으로 구분된 최소 8개의 필드)
|
|
|
|
|
string input = "C01\tN1\tP01\tR--\t16:15:14.123\t02/01/16\t0000098353\tA\t*\tPLR\tP\tLR 0.123456 sccm\tLR 0.123456 sccm\t\t\r\n";
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
string resultBody = SentinelParser.ExtractBody(input, out char resultType);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal('R', resultType);
|
|
|
|
|
Assert.Equal(input.Trim(), resultBody);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ExtractBody_AutoStreaming_NoHeader_ShouldReturnStreamingType()
|
|
|
|
|
{
|
|
|
|
|
// Arrange (헤더 없는 단순 스트리밍 데이터)
|
|
|
|
|
string input = "LR 0.123456 sccm\r\n";
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
string resultBody = SentinelParser.ExtractBody(input, out char resultType);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal('S', resultType);
|
|
|
|
|
Assert.Equal(input.Trim(), 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 ParseStreamingValue_NoHeader_ShouldParseValueAndUnit()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
string input = "LR -1.50 sccm\r\n";
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
ParsedData result = SentinelParser.ParseStreamingValue(input);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(-1.50, 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 ...
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ParseFinalResult_AutoResult_NoHeader_ShouldParseAllFields()
|
|
|
|
|
{
|
|
|
|
|
// Arrange (C28 매뉴얼 Appendix D 표와 정확히 동일한 형식의 Auto Result 데이터)
|
|
|
|
|
// Channel | Port | Prog | Link | Time | Date | UniqueId | Eval | SPC | Type | TestEval | TestData1
|
|
|
|
|
string input = "C01\tN1\tP01\tR--\t16:15:14.123\t02/01/16\t0000098353\tA\t*\tPLR\tP\tLR 0.123456 sccm\tLR 0.123456 sccm\t\t\r\n";
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
ParsedData result = SentinelParser.ParseFinalResult(input);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal("C01", result.ChannelNo);
|
|
|
|
|
Assert.Equal("P01", result.ProgramNo);
|
|
|
|
|
Assert.Equal("16:15:14.123", result.TestTime);
|
|
|
|
|
Assert.Equal("02/01/16", result.TestDate);
|
|
|
|
|
Assert.Equal("0000098353", result.UniqueId);
|
|
|
|
|
Assert.Equal("98353", result.SerialNo); // 마지막 5자리
|
|
|
|
|
Assert.Equal("OK", result.Judgment); // A -> OK
|
|
|
|
|
Assert.Equal("A", result.SensorJudgment);
|
|
|
|
|
Assert.Equal(0.123456, result.MeasuredValue);
|
|
|
|
|
Assert.Equal("sccm", result.Unit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ParseFinalResult_AutoResult_Reject_ShouldParseProperly()
|
|
|
|
|
{
|
|
|
|
|
// Arrange (불량 판정 시의 Auto Result 데이터 시뮬레이션)
|
|
|
|
|
string input = "C02\tN1\tP02\tR--\t16:15:15.000\t02/01/16\t1111111111\tR\t*\tPLR\tF\tLR 1.50 sccm\t\t\r\n";
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
ParsedData result = SentinelParser.ParseFinalResult(input);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal("C02", result.ChannelNo);
|
|
|
|
|
Assert.Equal("NG", result.Judgment); // R -> NG
|
|
|
|
|
Assert.Equal("R", result.SensorJudgment);
|
|
|
|
|
Assert.Equal(1.50, result.MeasuredValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|