public void ValidateMatchesCache_WithMismatchedDelegateTypeIndices_Throws() { var cache = new EntityQueryCache(1); var builder = new EntityQueryBuilder().WithAll <EcsTestTag>(); int index; fixed(int *delegateTypes = new[] { 1 }) index = cache.CreateCachedQuery(0, k_DummyGroup, ref builder, delegateTypes, 1); Assert.Throws <InvalidOperationException>(() => cache.ValidateMatchesCache(index, ref builder, null, 0)); // note: can't use a `fixed` var inside a closure, so below we implement a manual Assert.Throws InvalidOperationException testException0 = null; try { fixed(int *anotherDelegateTypes0 = new[] { 2 }) cache.ValidateMatchesCache(index, ref builder, anotherDelegateTypes0, 1); } catch (InvalidOperationException x) { testException0 = x; } Assert.NotNull(testException0); InvalidOperationException testException1 = null; try { fixed(int *anotherDelegateTypes1 = new[] { 1, 2 }) cache.ValidateMatchesCache(index, ref builder, anotherDelegateTypes1, 2); } catch (InvalidOperationException x) { testException1 = x; } Assert.NotNull(testException1); }
public void ValidateMatchesCache_WithMismatchedBuilder_Throws() { var cache = new EntityQueryCache(1); var builder = new EntityQueryBuilder().WithAll <EcsTestTag>(); var index = cache.CreateCachedQuery(0, k_DummyGroup, ref builder, null, 0); var anotherBuilder = new EntityQueryBuilder(); Assert.IsFalse(builder.ShallowEquals(ref anotherBuilder)); Assert.Throws <InvalidOperationException>(() => cache.ValidateMatchesCache(index, ref anotherBuilder, null, 0)); }
public void ValidateMatchesCache_WithValidMatch_DoesNotThrow() { var cache = new EntityQueryCache(1); int index; fixed(int *delegateTypes = new[] { 1 }) { var builder = new EntityQueryBuilder().WithAll <EcsTestTag>(); index = cache.CreateCachedQuery(0, k_DummyGroup, ref builder, delegateTypes, 1); } Assert.AreEqual(0, index); var testBuilder = new EntityQueryBuilder().WithAll <EcsTestTag>(); fixed(int *testDelegateTypes = new[] { 1 }) cache.ValidateMatchesCache(index, ref testBuilder, testDelegateTypes, 1); }