MockOf<T>
public sealed class MockOf<T>Delegate-based fluent object builder with no reflection or expression trees — safe for Unity’s IL2CPP/AOT backend.
Methods
Section titled “Methods”
New(Func)
Section titled “New(Func)”public static MockOf<T> New(Func<T> factory)Start a new builder using factory to allocate instances.
Parameters
| Name | Type |
|---|---|
factory |
System.Func{{T}} |
Returns
MockMagic.MockOf`1
public static MockOf<T> New()Start a new builder that allocates instances via T’s
public parameterless constructor (System.Activator.CreateInstance%60%601).
Convenience overload for plain POCOs; if your type has no public default
constructor, use MockMagic.MockOf%601.New(System.Func%7b%600%7d) instead.
Returns
MockMagic.MockOf`1
Set(Action)
Section titled “Set(Action)”public MockOf<T> Set(Action<T> setter)Register a setter invoked for every generated instance.
Parameters
| Name | Type |
|---|---|
setter |
System.Action{{T}} |
Returns
MockMagic.MockOf`1
Set(Action<T, int>)
Section titled “Set(Action<T, int>)”public MockOf<T> Set(Action<T, int> setter)Register a setter with access to the zero-based item index.
Parameters
| Name | Type |
|---|---|
setter |
System.Action{{T},System.Int32} |
Returns
MockMagic.MockOf`1
Finish(Action)
Section titled “Finish(Action)”public MockOf<T> Finish(Action<T> finisher)Register a finishing hook invoked after all setters run.
Parameters
| Name | Type |
|---|---|
finisher |
System.Action{{T}} |
Returns
MockMagic.MockOf`1
UseSeed(int)
Section titled “UseSeed(int)”public MockOf<T> UseSeed(int seed)Use a fixed seed for this builder’s generation pass. Internally re-seeds
MockMagic.MockRandom before MockMagic.MockOf%601.Generate / MockMagic.MockOf%601.Generate(System.Int32).
Parameters
| Name | Type |
|---|---|
seed |
System.Int32 |
Returns
MockMagic.MockOf`1
Generate()
Section titled “Generate()”public T Generate()Generate a single instance.
Returns
{T}
Generate(int)
Section titled “Generate(int)”public T[] Generate(int count)Generate count instances as an array.
Parameters
| Name | Type |
|---|---|
count |
System.Int32 |
Returns
{T}[]
GenerateLazy(int)
Section titled “GenerateLazy(int)”public IEnumerable<T> GenerateLazy(int count)Generate an System.Collections.Generic.IEnumerable%601 lazily, one instance at a time.
Parameters
| Name | Type |
|---|---|
count |
System.Int32 |
Returns
System.Collections.Generic.IEnumerable{{T}}
Operators
Section titled “Operators”
implicit operator T(MockOf)
Section titled “implicit operator T(MockOf)”public static implicit operator T(MockOf<T> builder)Implicit single-item generation, e.g. Order o = builder;.
Parameters
| Name | Type |
|---|---|
builder |
MockMagic.MockOf`1 |
Returns
{T}