public void IndexFramesPerNodeTest() { TracingTimeline.FramesPerNodeCache cached = default; var stencil = new TestStencil(); var n1 = NodeGuid(1); var n2 = NodeGuid(2); var n3 = NodeGuid(3); var graphTrace = new TestGraphTrace(0, 4, new Dictionary <int, SerializableGUID[]> { { 0, new[] { n1, n2 } }, // frame 0, nodes 1 and 3 are active { 1, new[] { n1, n3 } }, { 2, new[] { n3 } }, { 3, new[] { n1 } }, { 4, new[] { n1, n2 } }, }); Dictionary <SerializableGUID, List <(int InclusiveStartFrame, int ExclusiveEndFrame)> > index; index = TracingTimeline.IndexFramesPerNode(ref cached, stencil, graphTrace, 0, 2, 0, out bool invalidated); Assert.IsTrue(invalidated); CollectionAssert.AreEqual(new List <(int, int)> { (0, 2) }, index[n1]);
public void TestTypeSearcherItemString() { Stencil stencil = new TestStencil(); var item = new TypeSearcherItem(typeof(string).GenerateTypeHandle(stencil), typeof(string).FriendlyName()); Assert.AreEqual(item.Type, typeof(string).GenerateTypeHandle(stencil)); Assert.AreEqual(item.Name, typeof(string).FriendlyName()); }
public void TestTypeSearcherItemUnityObject() { Stencil stencil = new TestStencil(); var item = new TypeSearcherItem(typeof(Object).GenerateTypeHandle(stencil), "UnityEngine.Object"); Assert.AreEqual(item.Type, typeof(Object).GenerateTypeHandle(stencil)); Assert.AreEqual(item.Name, "UnityEngine.Object"); }
public void TestCanLoadAllTypesFromAssemblies() { // If this test fails, failing assemblies must be added to the Stencil.BlackListedAssemblies Assert.DoesNotThrow(() => { var stencil = new TestStencil(); var types = stencil.GetAssemblies() .SelectMany(a => a.GetTypesSafe(), (domainAssembly, assemblyType) => assemblyType) .Where(t => !t.IsAbstract && !t.IsInterface); Assert.IsNotNull(types); }); LogAssert.NoUnexpectedReceived(); }
static void DataWatchServiceDisableThrottling(bool value) { try { var stencil = new TestStencil(); var dataWatchServiceType = stencil.GetAssemblies() .SelectMany(a => a.GetTypesSafe(), (domainAssembly, assemblyType) => assemblyType) .First(x => x.Name == "DataWatchService"); var sharedInstance = dataWatchServiceType.GetProperty("sharedInstance", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null); dataWatchServiceType.GetProperty("disableThrottling", BindingFlags.NonPublic | BindingFlags.Static)?.SetValue(sharedInstance, value); } catch { Debug.LogWarning("DataWatchServiceDisableThrottling failed"); } }
public void TestComponents() { var stencil = new TestStencil(); var source = new List <ITypeMetadata> { stencil.GenerateTypeHandle(typeof(TestComponent)).GetMetadata(stencil), stencil.GenerateTypeHandle(typeof(TestSharedComponent)).GetMetadata(stencil), stencil.GenerateTypeHandle(typeof(string)).GetMetadata(stencil) }; var db = new EcsTypeSearcherDatabase(stencil, source).AddComponents().Build(); ValidateHierarchy(db.Search("", out _), new[] { new SearcherItem("Component Data", "", new List <SearcherItem> { new SearcherItem("UnityEditor", "", new List <SearcherItem> { new SearcherItem("VisualScriptingECSTests", "", new List <SearcherItem> { new SearcherItem("Stencils", "", new List <SearcherItem> { new TypeSearcherItem( typeof(TestComponent).GenerateTypeHandle(stencil), typeof(TestComponent).FriendlyName() ) }) }) }) }), new SearcherItem("Shared Component Data", "", new List <SearcherItem> { new SearcherItem("UnityEditor", "", new List <SearcherItem> { new SearcherItem("VisualScriptingECSTests", "", new List <SearcherItem> { new SearcherItem("Stencils", "", new List <SearcherItem> { new TypeSearcherItem( typeof(TestSharedComponent).GenerateTypeHandle(stencil), typeof(TestSharedComponent).FriendlyName() ) }) }) }) }) }); }