Exemple #1
0
        public void ComponentDataProxy_SetValue_SynchronizesWithEntityManager(
            Type proxyType, Constraint isDefaultValue, object expectedValue, MockSetter setValue, MockGetter getValue
            )
        {
            var           proxy = m_GameObjectEntity.gameObject.AddComponent(proxyType) as ComponentDataProxyBase;
            EntityManager entityManager;
            Entity        entity;

            Assume.That(
                proxy.CanSynchronizeWithEntityManager(out entityManager, out entity), Is.True,
                "EntityManager is not in correct state in arrangement for synchronization to occur"
                );
            var defaultValue = getValue(proxy);

            Assume.That(
                defaultValue, isDefaultValue,
                $"{proxy.GetType()} did not initialize with default value in arrangement"
                );

            setValue(proxy, expectedValue);
            new SerializedObject(proxy);

            var actual = getValue(proxy);

            Assert.That(actual, Is.EqualTo(expectedValue), $"Value was reset after deserializing {proxyType}");
        }
        public void ComponentDataProxy_WhenEntityManagerIsInvalid_SynchronizesWithEntityManager(
            Type proxyType, object expectedValue, MockSetter setValue, MockGetter getValue
        )
        {
            var entityManager = EntityManager.CreateEntityManagerInUninitializedState();
            k_EntityManagerBackingField.SetValue(m_GameObjectEntity, entityManager);
            Assume.That(entityManager.IsCreated, Is.False, "EntityManager was not in correct state in test arrangement");
            var proxy = m_GameObjectEntity.gameObject.AddComponent(proxyType) as ComponentDataProxyBase;

            setValue(proxy, expectedValue);

            var actual = getValue(proxy);
            Assert.That(actual, Is.EqualTo(expectedValue), $"Setting value on {proxyType} failed");
        }