Skip to main content

Editor Mock Mode ≥ 1.12.1

Unity only

Editor Mock Mode is specific to the Unity SDK. It has no equivalent on Android, iOS, Flutter or React Native.

When running in the Unity Editor, the SDK automatically routes all calls through a mock backend — no device build is needed for integration work. Navigation calls (Open, OpenPost, OpenCreatePost, OpenGroup) are recorded, async calls (ConnectUser, DisconnectUser) complete immediately, and all callbacks can be fired on demand. An IMGUI overlay shows the simulated screen. All mock code is compiled out of device builds via #if UNITY_EDITOR — zero runtime overhead in production.

Settings

Mock mode is on by default — no setup required. Configure before OctopusSDK.Initialize(...). If an OctopusMockSettings asset exists, its values take effect at Initialize and override any code-set toggles.

// Disable mock entirely — SDK is inert in the Editor
OctopusSDK.Mock.Enabled = false;

// Keep mock on but hide the IMGUI overlay
OctopusSDK.Mock.ShowOverlay = false;

OctopusSDK.Initialize("YOUR_API_KEY", ConnectionMode.SSO());

ShowOverlay can be toggled live during Play mode.

tip

You can also create an OctopusMockSettings ScriptableObject at Assets/OctopusSDK/Resources/OctopusMockSettings.asset. When present, it seeds EnabledByDefault, ShowOverlay, InitialNotSeenCount (used by UpdateNotSeenNotificationsCount), and SeedGroups (returned by FetchGroups / SyncFollowGroups). These values are applied at Initialize and override code-set toggles.

Driving callbacks manually

The following driver methods simulate native callbacks on demand. They fire unconditionally regardless of Mock.Enabled:

OctopusSDK.Mock.EmitNotSeenCount(3);
OctopusSDK.Mock.EmitLoginRequired();
OctopusSDK.Mock.EmitGroupsChanged(myGroups);
OctopusSDK.Mock.EmitNavigateToClientObject("article_42");
OctopusSDK.Mock.EmitModifyUser(ProfileField.NICKNAME);

Writing EditMode tests

OctopusSDK.Mock keeps a full call log. Call Reset() in [SetUp] to clear state between tests, then inspect results with typed accessors (LastOpenedPost, LastPrefilledPost, LastTrackedEvent, CurrentScreen) or LastCall("MethodName").

For custom inspection, iterate OctopusSDK.Mock.Calls — an ordered IReadOnlyList<Call> of every recorded call since the last Reset(). Each Call has a Method string and an Args array.

using NUnit.Framework;

public class MyOctopusTests
{
[SetUp]
public void SetUp()
{
OctopusSDK.Mock.Enabled = true; // Enabled is not reset by Reset() — restore explicitly if a test disabled it
OctopusSDK.Mock.Reset();
}

[Test]
public void OpenPost_RecordsPostId()
{
OctopusSDK.OpenPost("42");
Assert.AreEqual("42", OctopusSDK.Mock.LastOpenedPost);
}

[Test]
public void OpenCreatePost_RecordsPrefill()
{
OctopusSDK.OpenCreatePost(new OctopusPrefilledPost
{
Text = "Hello",
TopicId = "group_1"
});
Assert.AreEqual("Hello", OctopusSDK.Mock.LastPrefilledPost.Text);
Assert.AreEqual("group_1", OctopusSDK.Mock.LastPrefilledPost.TopicId);
}
}
note

All OctopusSDK.Mock members are Editor-only (#if UNITY_EDITOR) and compiled out of device builds — zero runtime overhead in production.