示例#1
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);
        }
示例#2
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.DoesNotThrow(() =>
                                EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial(entity)));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData>(entity)));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Partial <EcsTestData>(entity)));
        }
示例#3
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)));
 }
示例#4
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))));
        }
示例#5
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)));
        }
示例#6
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))));
        }
        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.Exact <EcsTestData, EcsTestData2>(entity)));
            Assert.Throws <AssertionException>(() =>
                                               EntitiesAssert.ContainsOnly(m_Manager, EntityMatch.Exact <EcsTestData, EcsTestData2, EcsTestData3>(entity)));

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