public void TestDeserializationFromAttributeTable() { IAttributeTable attributeTable = new AttributeTable(); AttributeTable entityAttributeTable = new AttributeTable(); const string TestValueString = "Test"; entityAttributeTable.SetValue(TestComponent.AttributeTestString, TestValueString); EntityConfiguration entityConfiguration = new EntityConfiguration { BlueprintId = TestBlueprintId, Configuration = entityAttributeTable }; attributeTable.SetValue(TestData.AttributeTestEntity, entityConfiguration); TestData testData = InspectorUtils.CreateFromAttributeTable <TestData>( this.testGame.EntityManager, InspectorType.GetInspectorType(typeof(TestData)), attributeTable); Assert.AreNotEqual(testData.TestEntity, 0); Assert.AreNotEqual(testData.TestEntity, -1); // Check entity. TestComponent testComponent = this.testGame.EntityManager.GetComponent <TestComponent>(testData.TestEntity); Assert.NotNull(testComponent); Assert.AreEqual(testComponent.TestString, TestValueString); }
public void TestCreateFromNullAttributeTable() { TestInspectorType testInspectorType = null; Assert.DoesNotThrow( () => { testInspectorType = InspectorUtils.CreateFromAttributeTable <TestInspectorType>( this.testGame.EntityManager, this.inspectorType, null); }); Assert.NotNull(testInspectorType); }
public void TestCreateFromAttributeTable() { IAttributeTable attributeTable = new AttributeTable(); const string TestValueString1 = "Test1"; const string TestValueString2 = "Test2"; attributeTable.SetValue(TestInspectorType.AttributeString1, TestValueString1); attributeTable.SetValue(TestInspectorType.AttributeString2, TestValueString2); TestInspectorType testInspectorType = InspectorUtils.CreateFromAttributeTable <TestInspectorType>( this.testGame.EntityManager, this.inspectorType, attributeTable); Assert.AreEqual(testInspectorType.String1, TestValueString1); Assert.AreEqual(testInspectorType.String2, TestValueString2); }
public void TestDeserializationFromAttributeTable() { IAttributeTable attributeTable = new AttributeTable(); const string TestValueString1 = "Test1"; const string TestValueString2 = "Test2"; attributeTable.SetValue(TestData.AttributeString1, TestValueString1); attributeTable.SetValue(TestData.AttributeString2, TestValueString2); IAttributeTable parentAttributeTable = new AttributeTable(); parentAttributeTable.SetValue(TestDataParent.AttributeTestData, attributeTable); TestDataParent testDataParent = InspectorUtils.CreateFromAttributeTable <TestDataParent>( this.testGame.EntityManager, this.parentInspectorType, parentAttributeTable); Assert.AreEqual(testDataParent.TestData.String1, TestValueString1); Assert.AreEqual(testDataParent.TestData.String2, TestValueString2); }