Пример #1
0
        public void GetSetSingleton()
        {
            m_Manager.CreateEntity(typeof(EcsTestData));

            EmptySystem.SetSingleton(new EcsTestData(10));
            Assert.AreEqual(10, EmptySystem.GetSingleton <EcsTestData>().value);
        }
Пример #2
0
        public void GetSetSingletonMultipleThrows()
        {
            m_Manager.CreateEntity(typeof(EcsTestData));
            m_Manager.CreateEntity(typeof(EcsTestData));

            Assert.Throws <InvalidOperationException>(() => EmptySystem.SetSingleton(new EcsTestData()));
            Assert.Throws <InvalidOperationException>(() => EmptySystem.GetSingleton <EcsTestData>());
        }
Пример #3
0
        public void GetSetSingletonMultipleComponents()
        {
            var entity = m_Manager.CreateEntity(typeof(EcsTestData3), typeof(EcsTestData), typeof(EcsTestData2));

            m_Manager.SetComponentData(entity, new EcsTestData(10));
            Assert.AreEqual(10, EmptySystem.GetSingleton <EcsTestData>().value);

            EmptySystem.SetSingleton(new EcsTestData2(100));
            Assert.AreEqual(100, m_Manager.GetComponentData <EcsTestData2>(entity).value0);
        }
Пример #4
0
        public void GetSetSingleton_ManagedComponents()
        {
            m_Manager.CreateEntity(typeof(EcsTestManagedComponent));

            const string kTestVal = "SomeString";

            EmptySystem.SetSingleton(new EcsTestManagedComponent()
            {
                value = kTestVal
            });
            Assert.AreEqual(kTestVal, EmptySystem.GetSingleton <EcsTestManagedComponent>().value);
        }
Пример #5
0
 public void GetSetSingletonZeroThrows()
 {
     Assert.Throws <InvalidOperationException>(() => EmptySystem.SetSingleton(new EcsTestData()));
     Assert.Throws <InvalidOperationException>(() => EmptySystem.GetSingleton <EcsTestData>());
 }