1
0

SandboxTest.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Content.Client.IoC;
  2. using Content.Client.Parallax.Managers;
  3. using Robust.Client;
  4. using Robust.Shared.Configuration;
  5. using Robust.Shared.ContentPack;
  6. using Robust.Shared.IoC;
  7. using Robust.Shared.Log;
  8. using Robust.UnitTesting;
  9. namespace Content.IntegrationTests.Tests.Utility;
  10. public sealed class SandboxTest
  11. {
  12. [Test]
  13. public async Task Test()
  14. {
  15. // Not using PoolManager.GetServerClient() because we want to avoid having to unnecessarily create & destroy a
  16. // server. This all becomes unnecessary if ever the test becomes non-destructive or the no-server option
  17. // actually creates a pair without a server.
  18. var logHandler = new PoolTestLogHandler("CLIENT");
  19. logHandler.ActivateContext(TestContext.Out);
  20. var options = new RobustIntegrationTest.ClientIntegrationOptions
  21. {
  22. ContentStart = true,
  23. OverrideLogHandler = () => logHandler,
  24. ContentAssemblies = new[]
  25. {
  26. typeof(Shared.Entry.EntryPoint).Assembly,
  27. typeof(Client.Entry.EntryPoint).Assembly
  28. },
  29. Options = new GameControllerOptions { LoadConfigAndUserData = false }
  30. };
  31. options.BeforeStart += () =>
  32. {
  33. IoCManager.Resolve<IModLoader>().SetModuleBaseCallbacks(new ClientModuleTestingCallbacks
  34. {
  35. ClientBeforeIoC = () =>
  36. {
  37. IoCManager.Register<IParallaxManager, DummyParallaxManager>(true);
  38. IoCManager.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error;
  39. IoCManager.Resolve<IConfigurationManager>()
  40. .OnValueChanged(RTCVars.FailureLogLevel, value => logHandler.FailureLevel = value, true);
  41. }
  42. });
  43. };
  44. using var client = new RobustIntegrationTest.ClientIntegrationInstance(options);
  45. await client.WaitIdleAsync();
  46. await client.CheckSandboxed(typeof(Client.Entry.EntryPoint).Assembly);
  47. await client.CheckSandboxed(typeof(Shared.IoC.SharedContentIoC).Assembly);
  48. }
  49. }