public void ContextSets() { var context = new Context(); var entity = context.CreateEntity("original"); var component = new AComponent("a1"); // set doesn't match until component is attached var setA = context.CreateSet(e => e.Contains <AComponent>()); { Assert.AreEqual(0, setA.Count); entity.Add(component); // set should automatically match after component is added foreach (var e in setA) { Assert.AreEqual(component, e.Get <AComponent>()); } Assert.AreEqual(1, setA.Count); } // B doesn't match 'entity' because it doesn't have a BComponent. { Assert.AreEqual(1, setA.Count); var setB = context.CreateSet(e => e.Contains <BComponent>()); Assert.AreEqual(0, setB.Count); } // A doesn't match because it must be A AND B { Assert.AreEqual(1, setA.Count); Assert.IsFalse(entity.Contains <BComponent>()); var setAandB = context.CreateSet(e => e.Contains <AComponent>() && e.Contains <BComponent>()); Assert.AreNotSame(setA, setAandB); Assert.AreEqual(0, setAandB.Count, "IEntity should not match, has no BComponent"); var entityAandB = context.CreateEntity("ab"); entityAandB.Add(new AComponent("ab test")); entityAandB.Add(new BComponent()); Assert.AreEqual(1, setAandB.Count, "IEntity should match, has A and B Components"); Assert.AreEqual(2, setA.Count, "Set A should now match both"); context.ReleaseEntity(entityAandB); Assert.AreEqual(0, setAandB.Count, "IEntity should not match, was removed."); } // another A set should also match { var setA2 = context.CreateSet(e => e.Contains <AComponent>()); foreach (var e in setA2) { Assert.AreEqual(component, e.Get <AComponent>()); } Assert.AreEqual(1, setA2.Count); } // set should not increase the entities matched if another component is added { Assert.AreEqual(1, setA.Count); entity.Add(new AComponent("inner")); Assert.AreEqual(1, setA.Count); } }
private void DrawComponent(AComponent component) { var type = component.GetType(); var changed = this.ToolSelector.Change(ref component, new Property(type.Name)); if (changed) { component.ChangeState.Change(); } }
public void Setup() { var serilogger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo .StringList(logLines = new List <string>()) .CreateLogger(); var logger = new SerilogLoggerProvider(serilogger).CreateLogger("Test"); sut = new AComponent(logger, new Settings()); }
public void RegComp(AComponent comp) { comp.owner = this; if (compHash.Add(comp.CTID)) { componentPool [comp.CTID] = comp; } else { throw new System.Exception("Duplicate Component Type \"" + ComponentType(comp.CTID) + "\""); } }
public void ContextSetRemoval() { var context = new Context(); var set = context.CreateSet(e => e.Contains <AComponent>()); var entity = context.CreateEntity("set"); var component = new AComponent("a1"); entity.Add(component); // sanity check Assert.AreEqual(1, set.Count); Assert.AreSame(entity, set.First()); Assert.AreSame(component, set.First().First()); // remove entity, should remove components context.ReleaseEntity(entity); Assert.AreEqual(0, set.Count); Assert.IsNull(set.FirstOrDefault()); }
static void Main(string[] args) { Console.WriteLine("REPARACIONES J&M"); Console.WriteLine("===========================================\n"); Console.WriteLine("Bienvenido Usuario!"); BaseKit kit_1 = new Kit_1(); Console.WriteLine($"Le ofrecemos el siguiente kit: {kit_1.Name}"); Console.WriteLine($"Precio: {kit_1.GetPrice()}\n"); AComponent component_1 = ProductsConcreteFactory.Instance.CreateComponent(EnumComponents.SPEAKER); Console.Write($"Al agregarle {component_1.Name} con un valor de: {component_1.GetPrice()}"); kit_1.Add(component_1); Console.Write($" al combo el precio final sería: {kit_1.GetPrice()}\n\n"); BaseKit kit_2 = new Kit_2(); Console.WriteLine($"Tambien tenemos el {kit_2.Name} a un valor de: {kit_2.GetPrice()}\n"); kit_1 = new Kit_1(); Console.WriteLine($"Ofrecemos us super mega combo de {kit_1.Name} y {kit_2.Name} a un valor de: "); List <BaseKit> kits = new List <BaseKit>(); kits.Add(kit_1); kits.Add(kit_2); ComposeKit mega_kit = new ComposeKit(kits); Console.Write(mega_kit.GetPrice() + "\n\n"); AComponent component_2 = ProductsConcreteFactory.Instance.CreateComponent(EnumComponents.SPEAKER); Console.WriteLine($"Como información adicional el {component_2} requiere un total de {component_2.ExpectedRequiredtime} horas necesarias para trabajarlo."); Console.Read(); }
public void Components() { var context = new Context(); // init var e = context.CreateEntity("e"); Assert.IsFalse(e.Contains <AComponent>()); Assert.IsFalse(e.Contains(typeof(AComponent))); // add var aComponent = new AComponent("a1"); e.Add(aComponent); Assert.IsTrue(e.Contains <AComponent>()); Assert.IsTrue(e.Contains(typeof(AComponent))); Assert.AreSame(aComponent, e.Get <AComponent>()); var bComponent = new BComponent(); Assert.IsFalse(e.Contains <BComponent>()); e.Add(bComponent); Assert.AreSame(bComponent, e.Get <BComponent>()); Assert.AreSame(aComponent, e.Get <AComponent>()); // replace var aComponent2 = new AComponent("a2"); Assert.AreNotSame(aComponent2, e.Get <AComponent>()); e.Add(aComponent2); Assert.AreSame(aComponent2, e.Get <AComponent>()); // remove e.Remove <AComponent>(); Assert.IsFalse(e.Contains <AComponent>()); Assert.IsNull(e.Get <AComponent>()); }
public void SetParent(AComponent parent) { this.parent = parent; }
public void RemoveChild(AComponent child) { this.children.Remove(child); }
public void AddChild(AComponent child) { this.children.Add(child); child.SetParent(this); }
public void AddChild(AComponent child) { this.children.Add(child); }
public void CanBeCreatedWithoutCommandLine() { var component = new AComponent(LoggerFactoryFactory.LoggerFor <AComponent>(), new Settings()); component.AnAction("something").ShouldNotBeNull(); }