예제 #1
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>());
        }
예제 #2
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);
        }
        public void TryGetSingleton()
        {
            m_Manager.CreateEntity(typeof(EcsTestData));

            EmptySystem.SetSingleton(new EcsTestData(10));
            var hasSingleTon = EmptySystem.TryGetSingleton <EcsTestData>(out var ecsTestData);

            Assert.IsTrue(hasSingleTon);
            Assert.AreEqual(10, ecsTestData.value);
        }
예제 #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>());
 }