45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using Heimdall.Domain.Entities;
|
|
using Shouldly;
|
|
|
|
namespace Heimdall.Domain.Tests.Entities;
|
|
|
|
public class AgentSettingTests
|
|
{
|
|
[Fact]
|
|
public void Create_agentsetting_should_set_properties()
|
|
{
|
|
var agentId = Guid.NewGuid();
|
|
var setting = new AgentSetting(agentId, "heartbeat.interval", "60");
|
|
|
|
setting.AgentId.ShouldBe(agentId);
|
|
setting.Key.ShouldBe("heartbeat.interval");
|
|
setting.Value.ShouldBe("60");
|
|
}
|
|
|
|
[Fact]
|
|
public void Key_should_be_lowercased_and_trimmed()
|
|
{
|
|
var setting = new AgentSetting(Guid.NewGuid(), " HeartBeat.Interval ", "30");
|
|
|
|
setting.Key.ShouldBe("heartbeat.interval");
|
|
}
|
|
|
|
[Fact]
|
|
public void Empty_key_should_throw()
|
|
{
|
|
Should.Throw<ArgumentException>(() => new AgentSetting(Guid.NewGuid(), "", "val"));
|
|
}
|
|
|
|
[Fact]
|
|
public void UpdateValue_should_change_value_and_timestamp()
|
|
{
|
|
var setting = new AgentSetting(Guid.NewGuid(), "key", "old");
|
|
var before = setting.UpdatedAt;
|
|
|
|
setting.UpdateValue("new");
|
|
|
|
setting.Value.ShouldBe("new");
|
|
setting.UpdatedAt.ShouldBeGreaterThanOrEqualTo(before);
|
|
}
|
|
}
|