public void Init() { // Set up definition. definition = new ComponentDefinition("test-component"); definition.AddAttribute <string>("a", "a_value"); definition.AddAttribute <float>("b", 3.14f); // Set up containing entity. containingEntity = new Entity(); // Create component. component = new Component(definition, containingEntity); }
public void Init() { // TODO: mock ComponentDefinition ComponentDefinition test = new ComponentDefinition("test"); test.AddAttribute <int>("a", 42); test.AddAttribute <int?>("n", 5); mockComponentRegistry = new Mock <IComponentRegistry>(); mockComponentRegistry.Setup(r => r.FindComponentDefinition("test")).Returns(test); entity = new Entity(); entity.componentRegistry = mockComponentRegistry.Object; mockHandlers = new Mock <IMockHandlers>(); }
public void ShouldConvertCompatibleDefaultValues() { ComponentDefinition def = new ComponentDefinition("defTypeTest"); def.AddAttribute <double>("c", 42.0); def.AddAttribute <int?>("e", null); def.AddAttribute <int?>("f", 34); Assert.Catch <AttributeDefinitionException>(delegate { def.AddAttribute <double>("d", 42); }); Assert.Catch <AttributeDefinitionException>(delegate { def.AddAttribute <double>("a", 42); }); Assert.Catch <AttributeDefinitionException>(delegate { def.AddAttribute <double>("b", 42f); }); Assert.Catch <AttributeDefinitionException>(delegate { def.AddAttribute <int>("g", 3.14); }); }
public void Init() { registry = new ComponentRegistry(); definition = new ComponentDefinition("test2"); definition.AddAttribute <int>("a", 42); }
public void ShouldAddAttributes() { definition.AddAttribute <int>("a", 42); definition.AddAttribute <float>("b"); }