.
This commit is contained in:
@@ -22,11 +22,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Engine\Engine.csproj" />
|
||||
<ProjectReference Include="..\Engine\Engine.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="src\" />
|
||||
<Folder Include="src\"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,67 +5,67 @@ namespace EngineTests.Scene;
|
||||
|
||||
public class GameObjectTests
|
||||
{
|
||||
private GameObject _gameObject;
|
||||
private GameObject _gameObject;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_gameObject = new GameObject();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Constructor_ShouldInitializeWithTransformComponent()
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
_gameObject = new GameObject();
|
||||
}
|
||||
Assert.That(_gameObject.Transform, Is.Not.Null);
|
||||
Assert.That(_gameObject.HasComponent<Transform>(), Is.True);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Constructor_ShouldInitializeWithTransformComponent()
|
||||
[Test]
|
||||
public void AddComponent_ShouldThrowIfComponentAlreadyExists()
|
||||
{
|
||||
_gameObject.AddComponent<Transform>();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => _gameObject.ProcessChanges());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddComponent_ShouldAddComponentToGameObject()
|
||||
{
|
||||
_gameObject.AddComponent<OrthographicCamera>();
|
||||
_gameObject.ProcessChanges();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(_gameObject.Transform, Is.Not.Null);
|
||||
Assert.That(_gameObject.HasComponent<Transform>(), Is.True);
|
||||
});
|
||||
}
|
||||
Assert.That(_gameObject.GetComponent<OrthographicCamera>(), Is.Not.Null);
|
||||
Assert.That(_gameObject.HasComponent<OrthographicCamera>(), Is.True);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddComponent_ShouldThrowIfComponentAlreadyExists()
|
||||
[Test]
|
||||
public void AddComponent_ShouldAddComponentToGameObjectWithArgs()
|
||||
{
|
||||
_gameObject.AddComponent<PerspectiveCamera>(99, 0.2f, 1001f);
|
||||
_gameObject.ProcessChanges();
|
||||
|
||||
var camera = _gameObject.GetComponent<PerspectiveCamera>()!;
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
_gameObject.AddComponent<Transform>();
|
||||
Assert.That(camera.FieldOfView, Is.EqualTo(99));
|
||||
Assert.That(camera.NearPlane, Is.EqualTo(0.2f));
|
||||
Assert.That(camera.FarPlane, Is.EqualTo(1001f));
|
||||
});
|
||||
}
|
||||
|
||||
Assert.Throws<ArgumentException>(() => _gameObject.ProcessChanges());
|
||||
}
|
||||
[Test]
|
||||
public void AddComponent_ShouldThrowIfComponentBaseTypeAlreadyExists()
|
||||
{
|
||||
_gameObject.AddComponent<OrthographicCamera>();
|
||||
_gameObject.AddComponent<PerspectiveCamera>();
|
||||
|
||||
[Test]
|
||||
public void AddComponent_ShouldAddComponentToGameObject()
|
||||
{
|
||||
_gameObject.AddComponent<OrthographicCamera>();
|
||||
_gameObject.ProcessChanges();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(_gameObject.GetComponent<OrthographicCamera>(), Is.Not.Null);
|
||||
Assert.That(_gameObject.HasComponent<OrthographicCamera>(), Is.True);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddComponent_ShouldAddComponentToGameObjectWithArgs()
|
||||
{
|
||||
_gameObject.AddComponent<PerspectiveCamera>(99, 0.2f, 1001f);
|
||||
_gameObject.ProcessChanges();
|
||||
|
||||
var camera = _gameObject.GetComponent<PerspectiveCamera>()!;
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(camera.FieldOfView, Is.EqualTo(99));
|
||||
Assert.That(camera.NearPlane, Is.EqualTo(0.2f));
|
||||
Assert.That(camera.FarPlane, Is.EqualTo(1001f));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddComponent_ShouldThrowIfComponentBaseTypeAlreadyExists()
|
||||
{
|
||||
_gameObject.AddComponent<OrthographicCamera>();
|
||||
_gameObject.AddComponent<PerspectiveCamera>();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => _gameObject.ProcessChanges());
|
||||
}
|
||||
Assert.Throws<ArgumentException>(() => _gameObject.ProcessChanges());
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user