void StubRegistration(QueryMatchID id, SetQueryArgs args, Dictionary <IMRObject, ChildMatchInfo> expectedMatches = null) { var module = ModuleLoaderCore.instance.GetModule <QueryPipelinesModule>(); module.GroupPipeline = m_GroupPipeline; m_GroupPipeline.Register(id, args); if (expectedMatches == null) { return; } var memberCount = 0; var setIndex = m_GroupPipeline.Data.MatchIdToIndex[id]; var memberIndices = m_GroupPipeline.Data.MemberIndices[setIndex]; // fake like we already acquired the match foreach (var child in expectedMatches) { var memberIndex = memberIndices[memberCount]; var matchInfo = child.Value; m_GroupPipeline.MemberData.BestMatchDataIds[memberIndex] = matchInfo.dataID; memberCount++; } }
// Test that when we insert a group's arguments, we insert one entry into the group data, // one entry per member into the member data, and generate an index mapping between them. // Since we have the lower-level query data tests, this mostly tests the mapping between groups & members public void RegisterGroupData() { var relations = TestUtils.GetRelations(m_GroupQueryTestObject); var args = TestUtils.DefaultSetArgs(relations); var queryMatchId = QueryMatchID.Generate(); m_Pipeline.Register(queryMatchId, args); Assert.True(m_Pipeline.Data.MatchIdToIndex.TryGetValue(queryMatchId, out var groupIndex)); // was the group order weight calculated upon registration? Assert.Greater(m_Pipeline.Data.OrderWeights[groupIndex], 0f); // one entry in the member indices for every member ? var memberIndices = m_Pipeline.Data.MemberIndices[groupIndex]; Assert.AreEqual(relations.children.Count, memberIndices.Length); foreach (var memberIndex in memberIndices) { // did all member objects get correctly inserted to the member data ? var memberObject = m_Pipeline.MemberData.ObjectReferences[memberIndex]; Assert.Contains(memberObject, relations.children.Keys); // is the member index within the bounds of the member data? Assert.Less(memberIndex, m_Pipeline.MemberData.Count); var memberships = m_Pipeline.MemberData.RelationMemberships[memberIndex]; // it's OK for the memberships entry to be null - that means this group member is not in any Relations if (memberships == null) { continue; } foreach (var membership in memberships) { Assert.LessOrEqual(membership.RelationIndex, relations.Count); } } // one entry in the relation index pairs indices for each relation ? var relationIndexPairs = m_Pipeline.Data.RelationIndexPairs[groupIndex]; Assert.AreEqual(relations.Count, relationIndexPairs.Length); foreach (var pair in relationIndexPairs) { Assert.AreNotEqual(pair.Child1, pair.Child2); // every member of these pairs should belong to our member indices Assert.Contains(pair.Child1, memberIndices); Assert.Contains(pair.Child2, memberIndices); } var localRelationIndexPairs = m_Pipeline.Data.LocalRelationIndexPairs[groupIndex]; Assert.AreEqual(relations.Count, localRelationIndexPairs.Length); foreach (var pair in localRelationIndexPairs) { Assert.AreNotEqual(pair.Child1, pair.Child2); // every member of these pairs should be an index less than the count of members this group has Assert.Less(pair.Child1, memberIndices.Length); Assert.Less(pair.Child2, memberIndices.Length); } // check that SearchData got initialized var searchData = m_Pipeline.Data.SearchData[groupIndex]; Assert.NotNull(searchData); Assert.AreEqual(searchData.MatchBuffer.SetSize, memberIndices.Length); Assert.AreEqual(searchData.MemberRatings.Length, memberIndices.Length); }