Skip to content

Commit

Permalink
Fix unit test component registration
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Jan 17, 2024
1 parent 3954c12 commit fe8a5f5
Show file tree
Hide file tree
Showing 2 changed files with 213 additions and 231 deletions.
76 changes: 36 additions & 40 deletions Content.Tests/ContentUnitTest.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,51 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenDreamClient;
using OpenDreamRuntime;
using OpenDreamRuntime.Rendering;
using OpenDreamShared;
using OpenDreamShared.Rendering;
using Robust.Shared.Analyzers;
using Robust.Shared.IoC;
using Robust.UnitTesting;
using EntryPoint = OpenDreamRuntime.EntryPoint;

namespace Content.Tests
{
[Virtual]
public class ContentUnitTest : RobustUnitTest
{
protected override void OverrideIoC()
{
base.OverrideIoC();

SharedOpenDreamIoC.Register();

if (Project == UnitTestProject.Server)
{
ServerContentIoC.Register(unitTests: true);
IoCManager.Register<IDreamMapManager, DummyDreamMapManager>();
}
else if (Project == UnitTestProject.Client)
{
ClientContentIoC.Register();
}
namespace Content.Tests;

[Virtual]
public class ContentUnitTest : RobustUnitTest {
protected override Type[] ExtraComponents { get; } = {
typeof(DMISpriteComponent),
typeof(DreamMobSightComponent)
};

protected override void OverrideIoC() {
base.OverrideIoC();

SharedOpenDreamIoC.Register();

if (Project == UnitTestProject.Server) {
ServerContentIoC.Register(unitTests: true);
IoCManager.Register<IDreamMapManager, DummyDreamMapManager>();
} else if (Project == UnitTestProject.Client) {
ClientContentIoC.Register();
}
}

protected override Assembly[] GetContentAssemblies()
{
var l = new List<Assembly>
{
typeof(OpenDreamShared.EntryPoint).Assembly
};

if (Project == UnitTestProject.Server)
{
l.Add(typeof(EntryPoint).Assembly);
}
else if (Project == UnitTestProject.Client)
{
l.Add(typeof(OpenDreamClient.EntryPoint).Assembly);
}

l.Add(typeof(ContentUnitTest).Assembly);

return l.ToArray();
protected override Assembly[] GetContentAssemblies() {
var l = new List<Assembly> {
typeof(OpenDreamShared.EntryPoint).Assembly
};

if (Project == UnitTestProject.Server) {
l.Add(typeof(EntryPoint).Assembly);
} else if (Project == UnitTestProject.Client) {
l.Add(typeof(OpenDreamClient.EntryPoint).Assembly);
}

l.Add(typeof(ContentUnitTest).Assembly);

return l.ToArray();
}
}

Loading

0 comments on commit fe8a5f5

Please sign in to comment.