コード例 #1
0
        public void ContainsOnly_WithMatchingCustomMatcher_DoesNotAssert()
        {
            m_Manager.CreateEntity();

            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Where(() => "Matcher #0", _ => true)));
        }
コード例 #2
0
        public void ContainsOnly_WithDataComparison()
        {
            var entity = m_Manager.CreateEntity(typeof(EcsTestData), typeof(EcsTestData2));

            m_Manager.SetComponentData(entity, new EcsTestData2(5));

            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>(entity)));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>()));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>(entity, new EcsTestData2(5))));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>(new EcsTestData2(5), entity)));

            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>(entity, new EcsTestData2(6))));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>(new EcsTestData2(6), entity)));

            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>(entity, new EcsTestData2(5))));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>(new EcsTestData2(5), entity)));
        }
コード例 #3
0
        public void ContainsOnly_WithNonEmptyEntity()
        {
            var entity = m_Manager.CreateEntity(typeof(EcsTestData), typeof(EcsTestData2));

            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Any(entity)));

            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>(entity)));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData>(entity)));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>(entity)));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData, EcsTestData2>(entity)));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2, EcsTestData3>(entity)));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData, EcsTestData2, EcsTestData3>(entity)));

            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>()));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData>()));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2>()));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData, EcsTestData2>()));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2, EcsTestData3>()));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData, EcsTestData2, EcsTestData3>()));
        }
コード例 #4
0
        public void ContainsOnly_WithEmptyEntity()
        {
            var entity = m_Manager.CreateEntity();

            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Any(entity)));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(entity)));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>(entity)));
        }
コード例 #5
0
        public void Contains_WithPartialMatch_DoesNotAssert()
        {
            var entity1 = m_Manager.CreateEntity(typeof(EcsTestData));
            var entity2 = m_Manager.CreateEntity();

            Assert.DoesNotThrow(() =>
                                EntitiesAssert.Contains(m_Manager, EntityMatch.Any(entity1)));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.Contains(m_Manager, EntityMatch.Exact <EcsTestData>()));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.Contains(m_Manager, EntityMatch.Exact(entity2)));
        }
コード例 #6
0
        public void SystemStateSharedKeepsValueAfterDestroy()
        {
            var entity = m_Manager.CreateEntity();

            m_Manager.AddSharedComponentData(entity, new SystemShared {
                Value = 123
            });
            m_Manager.DestroyEntity(entity);
            EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <CleanupEntity>(new SystemShared {
                Value = 123
            }));
        }
コード例 #7
0
        public void ContainsOnly_WithCustomMatcher_OnlyCalledOnce()
        {
            m_Manager.CreateEntity();
            m_Manager.CreateEntity();

            var(count0, count1) = (0, 10);
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager,
                                                            EntityMatch.Where(() => "Matcher #0", _ => { ++count0; return(true); }),
                                                            EntityMatch.Where(() => "Matcher #1", _ => { ++count1; return(true); })));

            Assert.AreEqual(1, count0);
            Assert.AreEqual(11, count1);
        }
コード例 #8
0
        public void ContainsOnly_WithParamTypeComparison()
        {
            var entity = m_Manager.CreateEntity(typeof(EcsTestData), typeof(EcsTestData2));

            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(typeof(EcsTestData2), entity, typeof(EcsTestData))));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(typeof(EcsTestData), new[] { typeof(EcsTestData2) })));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(entity, new[] { typeof(EcsTestData), typeof(EcsTestData2) })));

            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData2>(new[] { typeof(EcsTestData2) }, typeof(EcsTestData))));
        }
コード例 #9
0
        public void RemoveComponentTwiceIgnored()
        {
            var entity = m_Manager.CreateEntity();

            m_Manager.AddComponent <EcsTestData>(entity);

            EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>(entity));
            var removed0 = m_Manager.RemoveComponent <EcsTestData>(entity);

            EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(entity));
            var removed1 = m_Manager.RemoveComponent <EcsTestData>(entity);

            EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(entity));

            Assert.That(removed0, Is.True);
            Assert.That(removed1, Is.False);
        }
コード例 #10
0
        public void ContainsOnly_WithBufferElementData()
        {
            var entity = m_Manager.CreateEntity();
            var buffer = m_Manager.AddBuffer <EcsIntElement>(entity);

            buffer.Add(1);
            buffer.Add(5);
            buffer.Add(9);

            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsIntElement>()));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsIntElement[]>()));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <List <EcsIntElement> >()));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(new EcsIntElement[] { 1, 5, 9 })));
            Assert.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(EntityMatch.Component((EcsIntElement[] match) => match.Length == 3))));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(EntityMatch.Component((EcsIntElement[] match) => match.Length == 2))));
        }
コード例 #11
0
        public void ContainsOnly_WithMultipleEntityMatches_Throws()
        {
            var ex = Assert.Throws <ArgumentException>(() =>
                                                       EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(new Entity {
                Index = 1
            }, new Entity {
                Index = 2
            })));

            StringAssert.Contains("multiple Entity", ex.Message);

            ex = Assert.Throws <ArgumentException>(() =>
                                                   EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial(new Entity {
                Index = 1
            }, new Entity {
                Index = 2
            })));
            StringAssert.Contains("multiple Entity", ex.Message);
        }
コード例 #12
0
 public void ContainsOnly_WithNullTypeMatch_Throws()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact(null)));
     Assert.Throws <ArgumentNullException>(() =>
                                           EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>(null)));
     Assert.Throws <ArgumentNullException>(() =>
                                           EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial(null)));
     Assert.Throws <ArgumentNullException>(() =>
                                           EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData>(null)));
 }
コード例 #13
0
 public void ContainsOnly_WithEmptyEcs_Asserts()
 {
     Assert.Throws <AssertionException>(() =>
                                        EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Where(() => "", _ => true)));
 }
コード例 #14
0
        public void ContainsOnly_WithNonMatchingCustomMatcher_Asserts()
        {
            m_Manager.CreateEntity();

            var ex = Assert.Throws <AssertionException>(() =>
                                                        EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Where(() => "Matcher #0", _ => false)));

            StringAssert.Contains("Matcher #0", ex.Message);
        }