data package 정리

This commit is contained in:
logonkhi
2025-07-15 15:25:17 +09:00
parent 6bac7d53b1
commit cf97c6b61b
81 changed files with 909 additions and 466 deletions

View File

@@ -5,6 +5,7 @@ using System;
using System.Linq;
using UnityEngine;
using UVC.Data;
using UVC.Data.Core;
namespace UVC.Tests.Data
{

View File

@@ -3,7 +3,7 @@ using NUnit.Framework;
using System;
using System.Collections.Generic;
using UnityEngine;
using UVC.Data;
using UVC.Data.Core;
namespace UVC.Tests.Data
{

View File

@@ -6,6 +6,7 @@ using System;
using System.Linq;
using UnityEngine;
using UVC.Data;
using UVC.Data.Core;
namespace UVC.Tests.Data
{

View File

@@ -8,17 +8,19 @@ using System.Reflection;
using System.Threading;
using UnityEngine;
using UVC.Data;
using UVC.Data.Core;
using UVC.Data.Http;
namespace UVC.Tests.Data
{
/// <summary>
/// HttpPipeLine 클래스의 테스트를 위한 테스트 클래스입니다.
/// HttpDataFetcher 클래스의 테스트를 위한 테스트 클래스입니다.
/// </summary>
[TestFixture]
public class HttpPipeLineTests
public class HttpDataFetcherTests
{
// 테스트에 사용할 HttpPipeLine 인스턴스
private HttpPipeLine? pipeLine;
// 테스트에 사용할 HttpDataFetcher 인스턴스
private HttpDataFetcher? pipeLine;
/// <summary>
/// 각 테스트 실행 전에 호출되는 설정 메서드입니다.
@@ -26,7 +28,7 @@ namespace UVC.Tests.Data
[SetUp]
public void Setup()
{
pipeLine = new HttpPipeLine();
pipeLine = new HttpDataFetcher();
pipeLine.UseMockup = true; // MockHttpRequester 사용 설정
// 테스트를 위한 DataRepository 초기화
ClearDataRepository();
@@ -43,7 +45,7 @@ namespace UVC.Tests.Data
{
Setup();
Debug.Log("===== HttpPipeLine 테스트 시작 =====");
Debug.Log("===== HttpDataFetcher 테스트 시작 =====");
//RunTest(nameof(Add_NewInfo_AddedSuccessfully), Add_NewInfo_AddedSuccessfully);
//RunTest(nameof(Add_ExistingInfo_UpdatesExistingEntry), Add_ExistingInfo_UpdatesExistingEntry);
//await RunTestAsync(nameof(Remove_ExistingInfo_RemovedSuccessfullyAsync), Remove_ExistingInfo_RemovedSuccessfullyAsync);
@@ -77,7 +79,7 @@ namespace UVC.Tests.Data
await RunTestAsync(nameof(Test_Excute_WithArrayAndValidator_FiltersInvalidData), Test_Excute_WithArrayAndValidator_FiltersInvalidData);
Debug.Log("===== DataValidator 테스트 완료 =====");
Debug.Log("===== HttpPipeLine 테스트 완료 =====");
Debug.Log("===== HttpDataFetcher 테스트 완료 =====");
}
/// <summary>
@@ -114,13 +116,13 @@ namespace UVC.Tests.Data
}
/// <summary>
/// 새로운 HttpPipeLineInfo를 추가하는 테스트
/// 새로운 HttpRequestConfig를 추가하는 테스트
/// </summary>
[Test]
public void Add_NewInfo_AddedSuccessfully()
{
// Arrange
var info = new HttpPipeLineInfo("http://test.com");
var info = new HttpRequestConfig("http://test.com");
// Act
pipeLine.Add("test", info);
@@ -132,14 +134,14 @@ namespace UVC.Tests.Data
}
/// <summary>
/// 기존에 존재하는 키로 HttpPipeLineInfo를 추가할 때 업데이트 테스트
/// 기존에 존재하는 키로 HttpRequestConfig를 추가할 때 업데이트 테스트
/// </summary>
[Test]
public void Add_ExistingInfo_UpdatesExistingEntry()
{
// Arrange
var info1 = new HttpPipeLineInfo("http://test1.com");
var info2 = new HttpPipeLineInfo("http://test2.com");
var info1 = new HttpRequestConfig("http://test1.com");
var info2 = new HttpRequestConfig("http://test2.com");
pipeLine.Add("test", info1);
// Act
@@ -153,13 +155,13 @@ namespace UVC.Tests.Data
}
/// <summary>
/// 존재하는 HttpPipeLineInfo를 제거하는 테스트
/// 존재하는 HttpRequestConfig를 제거하는 테스트
/// </summary>
[Test]
public async UniTask Remove_ExistingInfo_RemovedSuccessfullyAsync()
{
// Arrange
var info = new HttpPipeLineInfo("http://test.com");
var info = new HttpRequestConfig("http://test.com");
pipeLine.Add("test", info);
// Act
@@ -177,7 +179,7 @@ namespace UVC.Tests.Data
public async UniTask Remove_NonExistingInfo_DoesNothing()
{
// Arrange
var info = new HttpPipeLineInfo("http://test.com");
var info = new HttpRequestConfig("http://test.com");
pipeLine.Add("test", info);
// Act - 존재하지 않는 키 제거 시도
@@ -190,14 +192,14 @@ namespace UVC.Tests.Data
}
/// <summary>
/// HttpPipeLine의 private infoList 필드 가져오기
/// HttpDataFetcher의 private infoList 필드 가져오기
/// </summary>
private Dictionary<string, HttpPipeLineInfo> GetInfoListField()
private Dictionary<string, HttpRequestConfig> GetInfoListField()
{
var fieldInfo = typeof(HttpPipeLine).GetField("infoList",
var fieldInfo = typeof(HttpDataFetcher).GetField("infoList",
BindingFlags.NonPublic | BindingFlags.Instance);
return (Dictionary<string, HttpPipeLineInfo>)fieldInfo.GetValue(pipeLine);
return (Dictionary<string, HttpRequestConfig>)fieldInfo.GetValue(pipeLine);
}
/// <summary>
@@ -246,8 +248,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// HttpPipeLineInfo 설정
var info = new HttpPipeLineInfo("http://test.com")
// HttpRequestConfig 설정
var info = new HttpRequestConfig("http://test.com")
.setDataMapper(dataMapper)
.setSuccessHandler((data) =>
{
@@ -304,8 +306,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// HttpPipeLineInfo 설정
var info = new HttpPipeLineInfo("http://test.com")
// HttpRequestConfig 설정
var info = new HttpRequestConfig("http://test.com")
.setDataMapper(dataMapper)
.setSuccessHandler((data) =>
{
@@ -381,8 +383,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// HttpPipeLineInfo 설정
var info = new HttpPipeLineInfo(agvUrl, "get")
// HttpRequestConfig 설정
var info = new HttpRequestConfig(agvUrl, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) =>
{
@@ -435,8 +437,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// HttpPipeLineInfo 설정
var info = new HttpPipeLineInfo(alarmUrl, "get")
// HttpRequestConfig 설정
var info = new HttpRequestConfig(alarmUrl, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) =>
{
@@ -515,11 +517,11 @@ namespace UVC.Tests.Data
}
};
// 각 데이터 타입별 HttpPipeLineInfo 설정 및 등록
// 각 데이터 타입별 HttpRequestConfig 설정 및 등록
foreach (var item in urls)
{
string key = item.Key;
var info = new HttpPipeLineInfo(item.Value, "get")
var info = new HttpRequestConfig(item.Value, "get")
.setDataMapper(new DataMapper(dataMasks[key]))
.setSuccessHandler((data) =>
{
@@ -569,8 +571,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// HttpPipeLineInfo 설정
var info = new HttpPipeLineInfo(testUrl, "get")
// HttpRequestConfig 설정
var info = new HttpRequestConfig(testUrl, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) =>
{
@@ -647,8 +649,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// HttpPipeLineInfo 설정
var info = new HttpPipeLineInfo(baseInfoUrl, "get")
// HttpRequestConfig 설정
var info = new HttpRequestConfig(baseInfoUrl, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) =>
{
@@ -733,8 +735,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// 반복 실행 설정을 포함한 HttpPipeLineInfo 생성
var info = new HttpPipeLineInfo(testUrl, "get")
// 반복 실행 설정을 포함한 HttpRequestConfig 생성
var info = new HttpRequestConfig(testUrl, "get")
.setDataMapper(dataMapper)
.setSuccessHandler(async (data) =>
{
@@ -807,8 +809,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// 무한 반복 설정을 포함한 HttpPipeLineInfo 생성
var info = new HttpPipeLineInfo(testUrl, "get")
// 무한 반복 설정을 포함한 HttpRequestConfig 생성
var info = new HttpRequestConfig(testUrl, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) => { handlerCallCount++; })
.setRepeat(true, 0, repeatInterval, false); // 무한 반복 (repeatCount = 0)
@@ -876,12 +878,12 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// 두 개의 반복 요청 설정
var info1 = new HttpPipeLineInfo(testUrl1, "get")
var info1 = new HttpRequestConfig(testUrl1, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) => { handlerCallCount1++; })
.setRepeat(true, 0, repeatInterval1, false);
var info2 = new HttpPipeLineInfo(testUrl2, "get")
var info2 = new HttpRequestConfig(testUrl2, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) => { handlerCallCount2++; })
.setRepeat(true, 0, repeatInterval2, false);
@@ -957,8 +959,8 @@ namespace UVC.Tests.Data
var dataMapper = new DataMapper(dataMask);
// 반복 횟수가 지정된 HttpPipeLineInfo 생성
var info = new HttpPipeLineInfo(testUrl, "get")
// 반복 횟수가 지정된 HttpRequestConfig 생성
var info = new HttpRequestConfig(testUrl, "get")
.setDataMapper(dataMapper)
.setSuccessHandler((data) =>
{
@@ -1003,11 +1005,11 @@ namespace UVC.Tests.Data
}
/// <summary>
/// HttpPipeLine의 private repeatTokenSources 필드 가져오기
/// HttpDataFetcher의 private repeatTokenSources 필드 가져오기
/// </summary>
private Dictionary<string, CancellationTokenSource> GetRepeatTokenSourcesField()
{
var fieldInfo = typeof(HttpPipeLine).GetField("repeatTokenSources",
var fieldInfo = typeof(HttpDataFetcher).GetField("repeatTokenSources",
BindingFlags.NonPublic | BindingFlags.Instance);
return (Dictionary<string, CancellationTokenSource>)fieldInfo.GetValue(pipeLine);
@@ -1154,11 +1156,12 @@ namespace UVC.Tests.Data
// "status" 필드가 "active"인 경우에만 유효하도록 설정
var validator = new DataValidator();
validator.AddValidator("status", value => {
return value is string s && s == "active";
validator.AddValidator("status", value =>
{
return value is string s && s == "active";
});
var info = new HttpPipeLineInfo(testUrl)
var info = new HttpRequestConfig(testUrl)
.setDataMapper(dataMapper)
.setValidator(validator)
.setSuccessHandler(data =>
@@ -1208,7 +1211,7 @@ namespace UVC.Tests.Data
var validator = new DataValidator();
validator.AddValidator("status", value => value is string s && s == "active");
var info = new HttpPipeLineInfo(testUrl)
var info = new HttpRequestConfig(testUrl)
.setDataMapper(dataMapper)
.setValidator(validator)
.setSuccessHandler(data =>
@@ -1257,11 +1260,12 @@ namespace UVC.Tests.Data
// "value"가 15보다 큰 항목만 유효하도록 설정
var validator = new DataValidator();
validator.AddValidator("value", value => {
return value is int v && v > 15;
validator.AddValidator("value", value =>
{
return value is int v && v > 15;
});
var info = new HttpPipeLineInfo(testUrl)
var info = new HttpRequestConfig(testUrl)
.setDataMapper(dataMapper)
.setValidator(validator)
.setSuccessHandler(data =>

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a46a845a86ba29c49b6ab4fe038b374a

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: e90362e4ba6e6bf4bb2c320d28f13403

View File

@@ -1,21 +1,20 @@
#nullable enable
using Cysharp.Threading.Tasks;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UVC.Data;
using UVC.Data.Core;
using UVC.Data.Mqtt;
using UVC.Log;
namespace UVC.Tests.Data
{
[TestFixture]
public class MQTTPipeLineTests
public class MqttDataReceiverTests
{
private MQTTPipeLine pipeLine;
private MqttDataReceiver mqttReceiver;
private Dictionary<string, TestDataHandler> handlers;
private Dictionary<string, DataMask> dataMasks;
private readonly string[] topicNames = { "AGV", "CARRIER", "STOCKER_STACK", "ALL" };
@@ -25,8 +24,9 @@ namespace UVC.Tests.Data
public void Setup()
{
// 기본 테스트 환경 설정
pipeLine = new MQTTPipeLine("localhost", 1883);
pipeLine.UseMockup = true; // 테스트에서는 항상 MockMQTTService 사용
mqttReceiver = new MqttDataReceiver();
mqttReceiver.SetDomainPort("localhost", 1883);
mqttReceiver.UseMockup = true; // 테스트에서는 항상 MockMQTTService 사용
// 핸들러와 데이터 마스크 초기화
handlers = new Dictionary<string, TestDataHandler>();
@@ -43,7 +43,7 @@ namespace UVC.Tests.Data
public async UniTask TestAll()
{
Setup();
Debug.Log("===== MQTTPipeLine 테스트 시작 =====");
Debug.Log("===== MqttDataReceiver 테스트 시작 =====");
// 하나씩 테스트 해야 함
//await RunTestAsync(nameof(ExecutePipeLine_AllTopics_RegistersAndHandlesMessages), ExecutePipeLine_AllTopics_RegistersAndHandlesMessages);
//await RunTestAsync(nameof(RemoveTopic_ShouldStopReceivingMessages), RemoveTopic_ShouldStopReceivingMessages);
@@ -57,7 +57,7 @@ namespace UVC.Tests.Data
//await RunTestAsync(nameof(OnTopicMessage_WithValidData_ValidatorPassesAsync), OnTopicMessage_WithValidData_ValidatorPassesAsync);
//await RunTestAsync(nameof(OnTopicMessage_WithInvalidData_ValidatorFailsAsync), OnTopicMessage_WithInvalidData_ValidatorFailsAsync);
await RunTestAsync(nameof(OnTopicMessage_WithArrayAndValidator_FiltersInvalidDataAsync), OnTopicMessage_WithArrayAndValidator_FiltersInvalidDataAsync);
Debug.Log("===== MQTTPipeLine 테스트 완료 =====");
Debug.Log("===== MqttDataReceiver 테스트 완료 =====");
}
private void RunTest(string testName, Action testAction)
@@ -92,8 +92,8 @@ namespace UVC.Tests.Data
public void TearDown()
{
// 테스트 완료 후 리소스 정리
pipeLine.Stop();
pipeLine.Dispose();
mqttReceiver.Stop();
mqttReceiver.Dispose();
}
private DataMask CreateDataMaskForTopic(string topic)
@@ -282,16 +282,16 @@ namespace UVC.Tests.Data
// 필요한 UpdatedDataOnly 설정
bool updatedDataOnly = topic != "ALL";
var pipelineInfo = new MQTTPipeLineInfo(topic, updatedDataOnly)
var pipelineInfo = new MqttSubscriptionConfig(topic, updatedDataOnly)
.setDataMapper(new DataMapper(dataMasks[topic]))
.setHandler(handlers[topic].HandleData);
pipeLine.Add(pipelineInfo);
mqttReceiver.Add(pipelineInfo);
}
Debug.Log("파이프라인 설정 완료.");
// Act - 파이프라인 실행
pipeLine.Execute();
Debug.Log("파이프라인 Execute.");
mqttReceiver.Start();
Debug.Log("파이프라인 Start.");
// Assert - 일정 시간 기다린 후 각 핸들러가 호출되었는지 확인
await UniTask.Delay(1500);
@@ -313,12 +313,12 @@ namespace UVC.Tests.Data
{
// Arrange
// AGV 토픽만 등록
var agvInfo = new MQTTPipeLineInfo("AGV", true)
var agvInfo = new MqttSubscriptionConfig("AGV", true)
.setDataMapper(new DataMapper(dataMasks["AGV"]))
.setHandler(handlers["AGV"].HandleData);
pipeLine.Add(agvInfo);
pipeLine.Execute();
mqttReceiver.Add(agvInfo);
mqttReceiver.Start();
// 메시지가 수신되도록 잠시 대기
await UniTask.Delay(1000);
@@ -328,7 +328,7 @@ namespace UVC.Tests.Data
Assert.IsTrue(initialCallCount > 0, "초기 AGV 토픽의 핸들러가 호출되지 않았습니다.");
// Act
pipeLine.Remove("AGV"); // AGV 토픽 제거
mqttReceiver.Remove("AGV"); // AGV 토픽 제거
// 핸들러 초기화
handlers["AGV"].Reset();
@@ -344,11 +344,11 @@ namespace UVC.Tests.Data
public async UniTask UpdatedDataOnly_ShouldOnlyCallHandlerForUpdatedData()
{
// Arrange - 파이프라인 설정
// TestMQTTPipeLine을 사용하여 직접 메시지를 보낼 수 있게 함
var testPipeLine = new TestMQTTPipeLine();
// TestMqttDataReceiver을 사용하여 직접 메시지를 보낼 수 있게 함
var testPipeLine = new TestMqttDataReceiver();
// UpdatedDataOnly가 true인 AGV 토픽 추가
var agvInfo = new MQTTPipeLineInfo("AGV", true)
var agvInfo = new MqttSubscriptionConfig("AGV", true)
.setDataMapper(new DataMapper(dataMasks["AGV"]))
.setHandler(handlers["AGV"].HandleData);
@@ -375,12 +375,12 @@ namespace UVC.Tests.Data
public void OnTopicMessage_ValidJsonObject_CallsHandler()
{
// Arrange
var testPipeLine = new TestMQTTPipeLine();
var testPipeLine = new TestMqttDataReceiver();
foreach (var topic in topicNames)
{
bool updatedDataOnly = topic != "ALL";
var pipelineInfo = new MQTTPipeLineInfo(topic, updatedDataOnly)
var pipelineInfo = new MqttSubscriptionConfig(topic, updatedDataOnly)
.setDataMapper(new DataMapper(dataMasks[topic]))
.setHandler(handlers[topic].HandleData);
@@ -406,9 +406,9 @@ namespace UVC.Tests.Data
public void OnTopicMessage_JsonArray_CallsHandler()
{
// Arrange
var testPipeLine = new TestMQTTPipeLine();
var testPipeLine = new TestMqttDataReceiver();
var pipelineInfo = new MQTTPipeLineInfo("AGV", true)
var pipelineInfo = new MqttSubscriptionConfig("AGV", true)
.setDataMapper(new DataMapper(dataMasks["AGV"]))
.setHandler(handlers["AGV"].HandleData);
@@ -430,9 +430,9 @@ namespace UVC.Tests.Data
public void OnTopicMessage_EmptyMessage_DoesNotCallHandler()
{
// Arrange
var testPipeLine = new TestMQTTPipeLine();
var testPipeLine = new TestMqttDataReceiver();
var pipelineInfo = new MQTTPipeLineInfo("AGV", true)
var pipelineInfo = new MqttSubscriptionConfig("AGV", true)
.setDataMapper(new DataMapper(dataMasks["AGV"]))
.setHandler(handlers["AGV"].HandleData);
@@ -449,9 +449,9 @@ namespace UVC.Tests.Data
public void OnTopicMessage_InvalidJson_DoesNotCallHandler()
{
// Arrange
var testPipeLine = new TestMQTTPipeLine();
var testPipeLine = new TestMqttDataReceiver();
var pipelineInfo = new MQTTPipeLineInfo("AGV", true)
var pipelineInfo = new MqttSubscriptionConfig("AGV", true)
.setDataMapper(new DataMapper(dataMasks["AGV"]))
.setHandler(handlers["AGV"].HandleData);
@@ -476,12 +476,13 @@ namespace UVC.Tests.Data
dataMask.ObjectName = "AGV";
dataMask.ObjectIdKey = "VHL_NAME";
// 3. MQTTPipeLine 설정 (MockMQTTService 사용)
var pipeline = new MQTTPipeLine("localhost", 1883);
// 3. MqttDataReceiver 설정 (MockMQTTService 사용)
var pipeline = new MqttDataReceiver();
pipeline.SetDomainPort("localhost", 1883);
pipeline.UseMockup = true; // MockMQTTService 사용 설정
// 4. UpdatedDataOnly=true로 토픽 등록
var pipelineInfo = new MQTTPipeLineInfo("AGV", true)
var pipelineInfo = new MqttSubscriptionConfig("AGV", true)
.setDataMapper(new DataMapper(dataMask))
.setHandler(handler.HandleData);
@@ -489,7 +490,7 @@ namespace UVC.Tests.Data
// Act
// 파이프라인 실행 - 이것이 MockMQTTService를 통해 메시지를 보내기 시작
pipeline.Execute();
pipeline.Start();
// 첫 번째 데이터 세트가 수신될 때까지 대기
await UniTask.Delay(1500);
@@ -583,18 +584,19 @@ namespace UVC.Tests.Data
public async UniTask OnTopicMessage_WithValidData_ValidatorPassesAsync()
{
// Arrange
var testPipeLine = new TestMQTTPipeLine();
var testPipeLine = new TestMqttDataReceiver();
var handler = new TestDataHandler();
var dataMapper = new DataMapper(new DataMask { ["id"] = 0, ["status"] = "" });
// "status" 필드가 "active"인 경우에만 유효하도록 설정
var validator = new DataValidator();
validator.AddValidator("status", value => {
validator.AddValidator("status", value =>
{
Debug.Log($"Validator called with value: {value}, {value is string s2 && s2 == "active"}");
return value is string s && s == "active";
});
var pipelineInfo = new MQTTPipeLineInfo("test_topic")
var pipelineInfo = new MqttSubscriptionConfig("test_topic")
.setDataMapper(dataMapper)
.setValidator(validator)
.setHandler(handler.HandleData);
@@ -621,18 +623,19 @@ namespace UVC.Tests.Data
public async UniTask OnTopicMessage_WithInvalidData_ValidatorFailsAsync()
{
// Arrange
var testPipeLine = new TestMQTTPipeLine();
var testPipeLine = new TestMqttDataReceiver();
var handler = new TestDataHandler();
var dataMapper = new DataMapper(new DataMask { ["id"] = 0, ["status"] = "" });
// "status" 필드가 "active"인 경우에만 유효하도록 설정
var validator = new DataValidator();
validator.AddValidator("status", value => {
validator.AddValidator("status", value =>
{
Debug.Log($"Validator called with value2: {value}, {value is string s2 && s2 == "active"}");
return value is string s && s == "active";
});
var pipelineInfo = new MQTTPipeLineInfo("test_topic")
var pipelineInfo = new MqttSubscriptionConfig("test_topic")
.setDataMapper(dataMapper)
.setValidator(validator)
.setHandler(handler.HandleData);
@@ -657,7 +660,7 @@ namespace UVC.Tests.Data
public async UniTask OnTopicMessage_WithArrayAndValidator_FiltersInvalidDataAsync()
{
// Arrange
var testPipeLine = new TestMQTTPipeLine();
var testPipeLine = new TestMqttDataReceiver();
var handler = new TestDataHandler();
var dataMapper = new DataMapper(new DataMask { ["id"] = 0, ["value"] = 0 });
@@ -669,7 +672,7 @@ namespace UVC.Tests.Data
return value is int v && v > 15;
});
var pipelineInfo = new MQTTPipeLineInfo("test_topic")
var pipelineInfo = new MqttSubscriptionConfig("test_topic")
.setDataMapper(dataMapper)
.setValidator(validator)
.setHandler(handler.HandleData);
@@ -702,18 +705,19 @@ namespace UVC.Tests.Data
#endregion
}
// MQTTPipeLine의 OnTopicMessage 메서드를 테스트하기 위한 확장 클래스
public class TestMQTTPipeLine : MQTTPipeLine
// MqttDataReceiver의 OnTopicMessage 메서드를 테스트하기 위한 확장 클래스
public class TestMqttDataReceiver : MqttDataReceiver
{
public TestMQTTPipeLine() : base("localhost", 1883)
public TestMqttDataReceiver() : base()
{
UseMockup = true;
SetDomainPort("localhost", 1883);
}
public void TestOnTopicMessage(string topic, string message)
{
// private 메서드에 접근하기 위한 래퍼
typeof(MQTTPipeLine).GetMethod("OnTopicMessage",
typeof(MqttDataReceiver).GetMethod("OnTopicMessage",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance)?.Invoke(this, new object[] { topic, message });
}

View File

@@ -7,8 +7,8 @@ namespace UVC.Tests
public static void RunAllTests()
{
//new DataMapperTests().TestAll();
//new HttpPipeLineTests().TestAll();
//new MQTTPipeLineTests().TestAll();
//new HttpDataFetcherTests().TestAll();
//new MqttDataReceiverTests().TestAll();
//new DataObjectTests().TestAll();
new DataArrayTests().TestAll();
}