Firstborn/Library/PackageCache/com.unity.scriptablebuildpi.../Tests/Editor/BuildContextTests.cs
Schaken-Mods 7502018d20 Adding Mod Support
There is an asset in the store I grabbed. the coding is WAY above my head, I got about half of it and integrated and adapted what I can to it. im going as far as I can with it and ill come back in a few month when I understand t better.
2023-05-13 22:01:48 -05:00

49 lines
1.5 KiB
C#

using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.Build.Pipeline.Interfaces;
using UnityEngine;
namespace UnityEditor.Build.Pipeline.Tests
{
class MyContextObjectClass : IContextObject
{
}
interface ITestInterfaceWithContextDerivation : IContextObject {}
class TestITestInterfaceWithContextDerivationImplementation : ITestInterfaceWithContextDerivation
{}
public class BuildContextTests
{
BuildContext m_Ctx;
[SetUp]
public void Setup()
{
m_Ctx = new BuildContext();
}
[Test]
public void SetContextObject_WhenTypeDoesNotExist_AddsContextObject()
{
m_Ctx.SetContextObject(new MyContextObjectClass());
Assert.NotNull(m_Ctx.GetContextObject<MyContextObjectClass>());
}
[Test]
public void SetContextObject_WhenTypeHasInterfaceAssignableToContextObject_InterfaceAndObjectTypeUsedAsKey()
{
m_Ctx.SetContextObject(new TestITestInterfaceWithContextDerivationImplementation());
Assert.NotNull(m_Ctx.GetContextObject<ITestInterfaceWithContextDerivation>());
Assert.NotNull(m_Ctx.GetContextObject<TestITestInterfaceWithContextDerivationImplementation>());
}
[Test]
public void GetContextObject_WhenTypeDoesNotExist_Throws()
{
Assert.Throws(typeof(Exception), () => m_Ctx.GetContextObject<ITestInterfaceWithContextDerivation>());
}
}
}