diff --git a/sdk/node/Libplanet.Node.Tests/Services/ValidatorServiceTest.cs b/sdk/node/Libplanet.Node.Tests/Services/ValidatorServiceTest.cs new file mode 100644 index 00000000000..a81b2e4df5d --- /dev/null +++ b/sdk/node/Libplanet.Node.Tests/Services/ValidatorServiceTest.cs @@ -0,0 +1,42 @@ +using Libplanet.Node.Options; +using Libplanet.Node.Services; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace Libplanet.Node.Tests.Services; + +public class ValidatorServiceTest +{ + [Fact] + public void Enable_Test() + { + var settings = new Dictionary + { + [$"{SwarmOptions.Position}:{nameof(SwarmOptions.IsEnabled)}"] = "true", + [$"{ValidatorOptions.Position}:{nameof(ValidatorOptions.IsEnabled)}"] = "true", + }; + var serviceProvider = TestUtility.CreateServiceProvider(settings); + var validatorService = serviceProvider.GetRequiredService(); + Assert.NotNull(validatorService); + } + + [Fact] + public void Enable_WithoutSwarm_ThrowTest() + { + var settings = new Dictionary + { + [$"{ValidatorOptions.Position}:{nameof(ValidatorOptions.IsEnabled)}"] = "true", + }; + var serviceProvider = TestUtility.CreateServiceProvider(settings); + Assert.Throws( + serviceProvider.GetRequiredService); + } + + [Fact] + public void Disable_ThrowTest() + { + var serviceProvider = TestUtility.CreateServiceProvider(); + Assert.ThrowsAny( + serviceProvider.GetRequiredService); + } +}