diff --git a/Chickensoft.AutoInject.Tests/src/Dependent.cs b/Chickensoft.AutoInject.Tests/src/Dependent.cs
index 3c7cdba..9382040 100644
--- a/Chickensoft.AutoInject.Tests/src/Dependent.cs
+++ b/Chickensoft.AutoInject.Tests/src/Dependent.cs
@@ -21,6 +21,21 @@ public interface IDependent : ISuperNode {
/// Event invoked when dependencies have been resolved.
event Action? OnDependenciesResolved;
+ ///
+ /// True if the node is being unit-tested. When unit-tested, setup callbacks
+ /// will not be invoked.
+ ///
+ bool IsTesting { get; set; }
+
+ ///
+ /// Called after dependencies are resolved, but before
+ /// is called if (and only if)
+ /// is false. This allows you to initialize
+ /// properties that depend on dependencies separate from using those
+ /// properties to facilitate easier testing.
+ ///
+ void Setup() { }
+
///
/// Method that is invoked when all of the dependent node's dependencies are
/// resolved (after _Ready() but before _Process()).
@@ -53,7 +68,7 @@ void _AnnounceDependenciesResolved() { }
///
/// The resolved dependency value, the fallback value, or throws an exception
/// if the provider wasn't found during dependency resolution and a fallback
- /// value was not given
+ /// value was not given.
///
/// Thrown if the provider for
/// the requested value could not be found and when no fallback value is
@@ -73,6 +88,12 @@ public abstract partial class Dependent : Node, IDependent {
// These static stubs don't need to be copied over because we'll be copied
// into a SuperNode that declares these.
+ ///
+ /// True if the node is being unit-tested. When unit-tested, setup callbacks
+ /// will not be invoked.
+ ///
+ public bool IsTesting { get; set; } = false;
+
[PowerUpIgnore]
public static ImmutableDictionary
ScriptPropertiesAndFields { get; } =
@@ -395,6 +416,9 @@ ImmutableDictionary dependenciesToResolve
var providersInitializing = 0;
void resolve() {
+ if (!dependent.IsTesting) {
+ dependent.Setup();
+ }
dependent.OnResolved();
dependent._AnnounceDependenciesResolved();
}