mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 08:18:20 -04:00
* Move all unit tests to Engine/Tests * Fix Margin.EdgeSubtract * Fix Capsule.Contains * EnvironmentVariables.Remove if it's null * Fixed ray trace never returning startedsolid * Fix HistoryList.Navigate on empty list * Fix GameObject.WorldPosition accepting NaNs * Fix flex: initial expanding to the wrong grow/shrink * Translation.TryConvert shouldn't throw on invalid enum strings * Skip sound file tests on machines with no audio device
38 lines
836 B
C#
38 lines
836 B
C#
using System;
|
|
using Sandbox.Internal;
|
|
|
|
namespace SceneTests.GameObjects;
|
|
|
|
/// <summary>
|
|
/// Pins how deserialization behaves with bad input: a prefab instance referencing
|
|
/// a missing prefab warns and degrades instead of crashing.
|
|
/// </summary>
|
|
[TestClass]
|
|
public class SerializeRobustnessTest
|
|
{
|
|
|
|
/// <summary>
|
|
/// A prefab instance referencing a prefab that doesn't exist warns and degrades
|
|
/// instead of throwing.
|
|
/// </summary>
|
|
[TestMethod]
|
|
public void MissingPrefabWarnsInsteadOfThrowing()
|
|
{
|
|
var scene = new Scene();
|
|
using var sceneScope = scene.Push();
|
|
|
|
var json = Json.ParseToJsonObject( $$"""
|
|
{
|
|
"__guid": "{{Guid.NewGuid()}}",
|
|
"Name": "Ghost",
|
|
"__Prefab": "prefabs/does_not_exist.prefab"
|
|
}
|
|
""" );
|
|
|
|
var go = new GameObject();
|
|
go.Deserialize( json );
|
|
|
|
Assert.IsTrue( go.IsValid() );
|
|
}
|
|
}
|