Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Unity.Multiplayer.NetStats.Dispatch;
using Unity.Multiplayer.NetStats.Metrics;
using Unity.Multiplayer.NetStatsReporting;
using UnityEngine.Profiling;

namespace Unity.Netcode
{
Expand Down
3 changes: 3 additions & 0 deletions com.unity.netcode.gameobjects/Tests/Editor/Metrics.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#if MULTIPLAYER_TOOLS

using System;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using Unity.Multiplayer.MetricTypes;
using Unity.Multiplayer.NetStats.Dispatch;
using Unity.Multiplayer.NetStats.Metrics;

namespace Unity.Netcode.EditorTests.Metrics
{
public class NetworkMetricsRegistrationTests
{
static Type[] s_MetricTypes = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(x => x.GetTypes())
.Where(x => x.GetInterfaces().Contains(typeof(INetworkMetricEvent)))
.ToArray();

[TestCaseSource(nameof(s_MetricTypes))]
public void ValidateThatAllMetricTypesAreRegistered(Type metricType)
{
var dispatcher = new NetworkMetrics().Dispatcher as MetricDispatcher;
Assert.NotNull(dispatcher);

var collection = typeof(MetricDispatcher)
.GetField("m_Collection", BindingFlags.NonPublic | BindingFlags.Instance)?
.GetValue(dispatcher) as MetricCollection;
Assert.NotNull(collection);

Assert.That(
collection.Metrics,
Has.Exactly(2).Matches<IEventMetric>(
eventMetric =>
{
var eventType = eventMetric.GetType().GetGenericArguments()?.FirstOrDefault();
return eventType == metricType;
}));
}
}
}

#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
"rootNamespace": "Unity.Netcode.EditorTests",
"references": [
"Unity.Netcode.Runtime",
"Unity.Netcode.Editor"
"Unity.Netcode.Editor",
"Unity.Multiplayer.MetricTypes",
"Unity.Multiplayer.NetStats"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [
"Editor"
],
"versionDefines": [
{
"name": "com.unity.multiplayer.tools",
"expression": "",
"define": "MULTIPLAYER_TOOLS"
}
]
}
2 changes: 1 addition & 1 deletion testproject-tools-integration/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"dependencies": {
"com.unity.ide.rider": "3.0.7",
"com.unity.netcode.gameobjects": "file:../../com.unity.netcode.gameobjects",
"com.unity.multiplayer.tools": "0.0.1-preview.2",
"com.unity.multiplayer.tools": "0.0.1-preview.3",
"com.unity.multiplayer.transport.utp": "file:../../com.unity.multiplayer.transport.utp",
"com.unity.test-framework": "1.1.26",
"com.unity.modules.ai": "1.0.0",
Expand Down