public void GetSetSingleton() { m_Manager.CreateEntity(typeof(EcsTestData)); EmptySystem.SetSingleton(new EcsTestData(10)); Assert.AreEqual(10, EmptySystem.GetSingleton <EcsTestData>().value); }
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>()); }
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 GetSetSingleton_ManagedComponents() { m_Manager.CreateEntity(typeof(EcsTestManagedComponent)); const string kTestVal = "SomeString"; EmptySystem.SetSingleton(new EcsTestManagedComponent() { value = kTestVal }); Assert.AreEqual(kTestVal, EmptySystem.GetSingleton <EcsTestManagedComponent>().value); }
public void GetSetSingletonZeroThrows() { Assert.Throws <InvalidOperationException>(() => EmptySystem.SetSingleton(new EcsTestData())); Assert.Throws <InvalidOperationException>(() => EmptySystem.GetSingleton <EcsTestData>()); }