12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System.Collections.Generic;
- using LLM.Editor.Commands;
- using LLM.Editor.Data;
- using NUnit.Framework;
- namespace LLM.Editor.Tests.Unit
- {
- [TestFixture]
- public class GetProjectSettingSchemaCommandTests
- {
- private CommandContext _context;
- [SetUp]
- public void SetUp()
- {
- _context = new CommandContext();
- }
- [Test]
- public void Execute_WithValidApiClass_ReturnsSuccessAndSchema()
- {
- // Arrange
- var command = new GetProjectSettingSchemaCommand { apiClassName = "UnityEngine.Time" };
- // Act
- var result = command.Execute(_context);
- // Assert
- Assert.AreEqual(CommandOutcome.Success, result);
- Assert.IsInstanceOf<Dictionary<string, object>>(_context.CurrentSubject);
- var schema = (Dictionary<string, object>)_context.CurrentSubject;
- Assert.IsTrue(schema.ContainsKey("fixedDeltaTime"));
- Assert.IsTrue(schema.ContainsKey("timeScale"));
- }
- [Test]
- public void Execute_WithInvalidApiClass_ReturnsError()
- {
- // Arrange
- var command = new GetProjectSettingSchemaCommand { apiClassName = "UnityEngine.NonExistentClass" };
- // Act
- var result = command.Execute(_context);
- // Assert
- Assert.AreEqual(CommandOutcome.Error, result);
- Assert.IsTrue(_context.ErrorMessage.Contains("Could not find a class named"));
- }
- [Test]
- public void Execute_WithNullApiClass_ReturnsError()
- {
- // Arrange
- var command = new GetProjectSettingSchemaCommand { apiClassName = null };
- // Act
- var result = command.Execute(_context);
- // Assert
- Assert.AreEqual(CommandOutcome.Error, result);
- Assert.IsTrue(_context.ErrorMessage.Contains("'apiClassName' is required"));
- }
- }
- }
|