public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool tests, string label)> Tests() { yield return(model.Entities.Except(value.Entities()).None(), "Entities.Except().None()"); yield return(value.Entities().Has(_entity).Not(), "Entities.Has()"); yield return(value.Entities().Destroy(_entity).Not(), "Entities.Destroy()"); yield return(value.Entities().Count == model.Entities.Count, "Entities.Count"); yield return(_onPreDestroy.Length == _entities.Length, "OnPreDestroy.Length"); yield return(_onPreDestroy.First().Entity == _entity, "OnPreDestroy.First() == entity"); yield return(_onPreDestroy.Select(message => message.Entity).Except(_entities).None(), "OnPostDestroy.Except(entities).None()"); yield return(_onPostDestroy.Length == _entities.Length, "OnPostDestroy.Length"); yield return(_onPostDestroy.First().Entity == _entity, "OnPostDestroy.First() == entity"); yield return(_onPostDestroy.Select(message => message.Entity).Except(_entities).None(), "OnPostDestroy.Except(entities).None()"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool tests, string label)> Tests() { var entities = value.Entities(); var components = value.Components(); yield return(entities.Except(model.Entities).None(), "Entities.Except().None()"); yield return(entities.Distinct().SequenceEqual(entities), "Entities.Distinct()"); yield return(entities.Has(_entity), "Entities.Has()"); yield return(entities.Contains(_entity), "Entities.Contains()"); yield return(entities.Count == model.Entities.Count, "Entities.Count"); yield return(components.Get(_entity).None(), "Components.Get().None()"); yield return(components.State(_entity) == States.None, "Components.State() == States.None"); yield return(_onCreate.Length == 1 && _onCreate[0].Entity == _entity, "OnCreate"); yield return(components.Enable(_entity).Not(), "Components.Enable().Not()"); yield return(components.Disable(_entity).Not(), "Components.Disable().Not()"); yield return(components.Clear(_entity).Not(), "Components.Clear().Not()"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool test, string label)> Tests() { var components = value.Components(); yield return(_onAdd.All(message => message.Entity == _target && _missing.Contains(message.Component.Type)), "onAdd.All(missing.Contains())"); if (_success) { yield return(_sources.Length <= _copies.Length, "sources.Length <= copies.Length"); yield return(_targets.Length <= _copies.Length, "targets.Length <= copies.Length"); yield return(_copies.Length == _targets.Length + _missing.Length, "copies.Length == targets.Length + missing.Length"); yield return(_missing.Length == _onAdd.Length, "missing.Length == onAdd.Length"); yield return(_missing.All(type => components.Has(_target, type)), "missing.All(Has)"); yield return(_missing.All(type => components.TryGet(_target, type, out _)), "missing.All(TryGet)"); yield return(_missing.All(type => components.State(_target, type) == States.Enabled), "missing.All(Enabled)"); yield return(_missing.None(type => components.Enable(_target, type)), "missing.None(Enable)"); yield return(_sources.All(source => components.Has(_target, source.GetType())), "sources.All(Has(target, source.GetType()))"); } } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool test, string label)> Tests() { var components = value.Components(); yield return(_sources.Length >= _trimmed.Length, "sources.Length == trimmed.Length"); yield return(_targets.Length >= _trimmed.Length, "targets.Length >= trimmed.Length"); yield return(_trimmed.Length == _targets.Length - _exceeding.Length, "trimmed.Length == targets.Length - exceeding.Length"); yield return(_exceeding.Length == _onRemove.Length, "missing.Length == onRemove.Length"); yield return(_onRemove.All(message => message.Entity == _target && _exceeding.Contains(message.Component.Type)), "onRemove.All(exceeding.Contains())"); yield return(components.Count(_source) >= components.Count(_target, _include), "Count(source) >= Count(target)"); yield return(_trimmed.All(trimmed => components.Has(_source, trimmed.GetType())), "trimmed.All(Has(source, trimmed.GetType()))"); yield return(_exceeding.All(exceeding => components.Has(_source, exceeding).Not()), "exceeding.All(Has(source).Not())"); yield return(_exceeding.All(exceeding => components.Has(_target, exceeding, _include).Not()), "exceeding.All(Has(target).Not())"); } }
public override Property Check(World value, Model model) { var pointerA1 = _group.Select(item => *item.PointerA1).ToArray(); var pointerA2 = _group.Select(item => *item.PointerA2).ToArray(); var pointerB1 = _group.Select(item => *item.PointerB1).ToArray(); var pointerB2 = _group.Select(item => *item.PointerB2).ToArray(); var readA = _group.Select(item => item.ReadA.Value).ToArray(); var readB = _group.Select(item => item.ReadB.Value).ToArray(); var writeA = _group.Select(item => item.WriteA.Value).ToArray(); var writeB = _group.Select(item => item.WriteB.Value).ToArray(); return(base.Check(value, model).And(PropertyUtility.All(Tests()))); IEnumerable <(bool test, string label)> Tests() { if (_group == null) { yield break; } var entities = value.Entities(); var components = value.Components(); yield return(pointerA1.SequenceEqual(pointerA2), "pointerA1 == pointerA2"); yield return(pointerA1.SequenceEqual(readA), "pointerA1 == readA"); yield return(pointerA1.SequenceEqual(writeA), "pointerA1 == writeA"); yield return(pointerB1.SequenceEqual(pointerB2), "pointerB1 == pointerB2"); yield return(pointerB1.SequenceEqual(readB), "pointerB1 == readB"); yield return(pointerB1.SequenceEqual(writeB), "pointerB1 == writeB"); yield return(_group.Entities.SequenceEqual(_group.Select(item => item.Entity1)), "Entities == item.Entity1"); yield return(_group.Entities.SequenceEqual(_group.Select(item => item.Entity2)), "Entities == item.Entity2"); yield return(_group.Entities.SequenceEqual(_group.Select(item => item.Entity3)), "Entities == item.Entity3"); yield return(_group.All(item => item.Entity1 == item.Entity2 && item.Entity1 == item.Entity3 && item.Entity2 == item.Entity3), "Entity1 == Entity2 == Entity3"); yield return(_group.All(item => item.ReadA.State == item.WriteA.State), "ReadA.State == WriteA.State"); yield return(_group.All(item => item.ReadB.State == item.WriteB.State), "ReadB.State == WriteB.State"); yield return(_group.Segments.All(segment => segment.Select(item => item.ReadA.State).Same()), "segment.All(ReadA.State.Same()"); yield return(_group.Segments.All(segment => segment.Select(item => item.ReadB.State).Same()), "segment.All(ReadB.State.Same()"); yield return(_group.Segments.All(segment => segment.Select(item => item.WriteA.State).Same()), "segment.All(WriteA.State.Same()"); yield return(_group.Segments.All(segment => segment.Select(item => item.WriteB.State).Same()), "segment.All(WriteB.State.Same()"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool test, string label)> Tests() { var entities = value.Entities(); var components = value.Components(); yield return(components.Has(_include).Not(), "Components.Has().Not()"); yield return(components.Get(_include).None(), "Components.Get().None()"); yield return(components.Count(_include) == 0, "Components.Count == 0"); yield return(entities.None(entity => components.Has(entity, _include)), "Entities.None(Has())"); yield return(entities.All(entity => components.Get(entity, _include).None()), "Entities.All(Get().None())"); yield return(entities.All(entity => components.Count(entity, _include) == 0), "Entities.All(Get().None())"); yield return(entities.All(entity => components.State(entity).HasNone(_include)), "Entities.All(State().HasNone())"); yield return(_count > 0 == _success, "count == success"); yield return(_entities.Length > 0 == _success, "entities.Length == success"); yield return(_onRemove.Length > 0 == _success, "onRemove.Length == success"); yield return(_onRemove.Length == _count, "onRemove.Length == count"); yield return(_onRemove.Length >= _entities.Length, "onRemove.Length >= entities.Length"); yield return(_onRemove.Length == _count, "onRemove.Length == count"); yield return(_entities.Except(_onRemove.Select(message => message.Entity)).None(), "entities.Except(onRemove).None()"); if (_include.HasAny(States.Disabled)) { yield return(entities.None(entity => components.Enable(entity)), "Entities.None(Enable())"); } if (_include.HasAny(States.Enabled)) { yield return(entities.None(entity => components.Disable(entity)), "Entities.None(Disable())"); } yield return(entities.None(entity => components.Clear(entity, _include)), "Entities.None(Clear())"); yield return(components.Clear(_include).Not(), "Components.Clear().Not()"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool tests, string label)> Tests() { var entities = value.Entities(); var families = value.Families(); if (_success) { yield return(families.Parent(_child) == _parent, "Parent(child) == parent"); yield return(families.Ancestors(_child).Contains(_parent), "Ancestors(child).Contains(parent)"); yield return(families.Ancestors(_child).FirstOrDefault() == _parent, "Ancestors(child).First() == parent"); yield return(families.Has(_parent, _child), "Has(parent, child)"); yield return(families.Children(_parent).Contains(_child), "Children(parent).Contains(child)"); yield return(families.Descendants(_parent, From.Top).Contains(_child), "Descendants(parent, Top).Contains(child)"); yield return(families.Descendants(_parent, From.Bottom).Contains(_child), "Descendants(parent, Bottom).Contains(child)"); yield return(families.Family(_parent, From.Top).Contains(_child), "Family(parent, Top).Contains(child)"); yield return(families.Family(_parent, From.Bottom).Contains(_child), "Family(parent, Bottom).Contains(child)"); yield return(_onAdopt.Length == 1, "onAdopt.Length == 1"); yield return(_onAdopt.All(message => message.Child == _child), "onAdopt.All(message.Child == child)"); yield return(_onAdopt.All(message => message.Parent == _parent), "onAdopt.All(message.Parent == parent)"); } else { yield return(families.Parent(_child) != _parent, "Parent(child) != parent"); yield return(families.Ancestors(_child).Contains(_parent).Not(), "Ancestors(child).Contains(parent).Not()"); yield return(families.Descendants(_child, From.Top).Contains(_parent).Not(), "Descendants(child).Contains(parent).Not()"); yield return(families.Descendants(_parent, From.Top).Contains(_child).Not(), "Descendants(parent).Contains(child).Not()"); } yield return(families.Adopt(_parent, _child) == _success, "Adopt(parent, child) == success"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool test, string label)> Tests() { if (_group == null) { yield break; } yield return(_group.Count == _entities.Length, "Group.Count"); yield return(_group.Count == _group.Count(), "Group.Count()"); yield return(_group.ToArray().Length == _group.Count, "Group.ToArray()"); yield return(value.Groups().Get(_querier) == _group, "Groups.Get()"); yield return(_group.Querier.Equals(_querier), "Group.Query"); yield return(_group.Entities.OrderBy(_ => _).SequenceEqual(_entities.OrderBy(_ => _)), "Group.Entities"); yield return(_group.Entities.Count() == _group.Count, "Group.Entities.Count()"); yield return(_group.Entities.All(_group.Has), "Group.Entities.Has()"); yield return(_group.Entities.All(entity => _group.TryGet(entity, out _)), "Group.Entities.TryGet()"); yield return(_group.Split(0).None(), "Group.Split(0).None()"); for (int i = 1; i < 5; i++) { yield return(_group.Split(i).Sum(split => split.Count()) == _group.Count, $"Group.Split({i}).Count()"); } for (int i = 1; i < 5; i++) { yield return(_group.Split(i).Sum(split => split.Count) == _group.Count, $"Group.Split({i}).Count"); } yield return(_group.Segments.Sum(segment => segment.Count) == _group.Count, $"Group.Segments.Count"); yield return(_group.Segments.Sum(segment => segment.Count()) == _group.Count, $"Group.Segments.Count"); yield return(_entities.All(entity => _group.Has(entity)), "Group.Has()"); yield return(_entities.All(entity => _group.TryGet(entity, out _)), "Group.TryGet()"); } }
public override Property Check(World value, Model model) { return(base.Check(value, model).And(PropertyUtility.All(Tests()))); IEnumerable <(bool test, string label)> Tests() { if (_group == null) { yield break; } yield return(_group.SequenceEqual(_group.Entities), "Group.SequenceEqual(Entities)"); yield return(_group.All(_group.Has), "Group.All(Group.Has)"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool test, string label)> Tests() { var components = value.Components(); yield return(components.Has(_entity, _type, _include).Not(), "components.Has().Not()"); yield return(components.Get(_entity, _include).OfType(_type).None(), "components.Get().OfType(type).None()"); yield return(components.TryGet(_entity, _type, out _, _include).Not(), "components.TryGet().Not()"); yield return(components.State(_entity, _type).HasNone(_include), "components.State()"); yield return(_onRemove.All(message => message.Entity == _entity && message.Component.Type.Is(_type)), "OnRemove"); if (_success) { yield return(_onRemove.Length > 0, "onRemove.Length"); } else { yield return(_onRemove.Length == 0, "onRemove.Length"); } if (_include.HasAny(States.Disabled)) { yield return(components.Enable(_entity, _type).Not(), "components.Enable().Not()"); } if (_include.HasAny(States.Enabled)) { yield return(components.Disable(_entity, _type).Not(), "components.Disable().Not()"); } yield return(components.Remove(_entity, _type, _include).Not(), "components.Remove().Not()"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool test, string label)> Tests() { var components = value.Components(); yield return(components.Get(_entity, States.Enabled).OfType(_type).None(), "Components.Get(Enabled).None()"); yield return(components.TryGet(_entity, _type, out _, States.Enabled).Not(), "Components.TryGet(Type, Enabled).Not()"); yield return(components.Has(_entity, _type, States.Enabled).Not(), "Components.Has(Type, Enabled).Not()"); yield return(_onDisable.All(message => message.Entity == _entity && message.Component.Type.Is(_type)), "onDisable.All()"); if (_success) { yield return(components.State(_entity).HasAny(States.Disabled), "Components.State()"); yield return(components.State(_entity, _type).HasAny(States.Disabled), "Components.State()"); yield return(components.Has(States.Disabled), "Components.Has<T>(Disabled)"); yield return(components.Has(), "Components.Has<T>()"); yield return(components.Has(_type, States.Disabled), "Components.Has(type, Disabled)"); yield return(components.Has(_type), "Components.Has(type)"); yield return(components.Has(_entity, _type, States.Disabled), "Components.Has(entity, Type, Disabled)"); yield return(components.Has(_entity, _type), "Components.Has(entity, Type)"); yield return(components.Count(States.Disabled) > 0, "Components.Count(Disabled)"); yield return(components.Count() > 0, "Components.Count()"); yield return(components.Count(_type) > 0, "Components.Count(type)"); yield return(components.Count(_type, States.Disabled) > 0, "Components.Count(type, Disabled)"); yield return(components.Count(_entity, States.Disabled) > 0, "Components.Count(entity, Disabled)"); yield return(components.Count(_entity) > 0, "Components.Count(entity)"); yield return(components.Get().OfType(_type).Any(), "Components.Get().Any()"); yield return(components.Get(States.Disabled).OfType(_type).Any(), "Components.Get(Disabled).Any()"); yield return(components.Get(_entity, States.Disabled).OfType(_type).Any(), "Components.Get(Disabled).Any()"); yield return(components.Get(_entity).OfType(_type).Any(), "Components.Get().Any()"); yield return(components.TryGet(_entity, _type, out _), "Components.TryGet()"); yield return(components.TryGet(_entity, _type, out _, States.Disabled), "Components.TryGet(Disabled)"); yield return(_onDisable.Length > 0, "onDisable.Length > 0"); } else { yield return(_onDisable.Length == 0, "onDisable.Length == 0"); } yield return(components.Disable(_entity, _type).Not(), "Components.Disable(Type).Not()"); } }
public override Property Check(World value, Model model) { return(PropertyUtility.All(Tests())); IEnumerable <(bool test, string label)> Tests() { var entities = value.Entities(); var components = value.Components(); yield return(_has != _success, "Has != Add"); yield return(components.Has <TConcrete>(), "Components.Has<TConcrete>()"); yield return(components.Has <TAbstract>(), "Components.Has<TAbstract>()"); yield return(components.Has <IComponent>(), "Components.Has<IComponent>()"); yield return(components.Has(typeof(TConcrete)), "Components.Has(TConcrete)"); yield return(components.Has(typeof(TAbstract)), "Components.Has(TAbstract)"); yield return(components.Has(typeof(IComponent)), "Components.Has(IComponent)"); yield return(components.Has(_abstract), "Components.Has(abstract)"); yield return(components.Has <TConcrete>(_entity), "Components.Has<TConcrete>(Entity)"); yield return(components.Has <TAbstract>(_entity), "Components.Has<TAbstract>(Entity)"); yield return(components.Has <IComponent>(_entity), "Components.Has<IComponent>(Entity)"); yield return(components.Has(), "Components.Has()"); yield return(components.Has(_entity), "Components.Has(entity)"); yield return(components.Has(_entity, typeof(TConcrete)), "Components.Has(Entity, TConcrete)"); yield return(components.Has(_entity, typeof(TAbstract)), "Components.Has(Entity, TAbstract)"); yield return(components.Has(_entity, _abstract), "Components.Has(Entity, abstract)"); yield return(components.Has(_entity, typeof(IComponent)), "Components.Has(Entity, IComponent)"); yield return(components.Count <TConcrete>() == components.Count(typeof(TConcrete)), "Components.Count<TConcrete>() == Components.Count(TConcrete)"); yield return(components.Count <TAbstract>() == components.Count(typeof(TAbstract)), "Components.Count<TAbstract>() == Components.Count(TAbstract)"); yield return(components.Count <TConcrete>() == model.Components.Count(pair => pair.Value.Contains(typeof(TConcrete))), "Components.Count<TConcrete>() == model.Components"); yield return(components.Count <TConcrete>() == entities.Count(entity => components.Has <TConcrete>(entity)), "Components.Count<TConcrete>() == Entities.Components"); yield return(components.Count(typeof(TConcrete)) == model.Components.Count(pair => pair.Value.Contains(typeof(TConcrete))), "Components.Count(TConcrete) == model.Components"); yield return(components.Count(typeof(TConcrete)) == entities.Count(entity => components.Has(entity, typeof(TConcrete))), "Components.Count(TConcrete) == Entities.Components"); // NOTE: '>=' is used here because an entity may have more than one component of an abstract type yield return(components.Count <TAbstract>() >= entities.Count(entity => components.Has <TAbstract>(entity)), "Components.Count<TAbstract>() == Entities.Components"); yield return(components.Count(typeof(TAbstract)) >= entities.Count(entity => components.Has(entity, typeof(TAbstract))), "Components.Count(TAbstract) >= Entities.Components"); yield return(components.Count(_abstract) >= entities.Count(entity => components.Has(entity, _abstract)), "Components.Count(abstract) >= Entities.Components"); yield return(components.Count() > 0, "Components.Count() >= 0"); yield return(components.Count(_entity) > 0, "Components.Count(entity) >= 0"); yield return(components.Get().Any(), "Components.Get().Any()"); yield return(components.Get <TConcrete>().Any(), "Components.Get<TConcrete>().Any()"); yield return(components.Get(typeof(TConcrete)).Any(), "Components.Get(TConcrete).Any()"); yield return(components.Get(typeof(TAbstract)).Any(), "Components.Get(TAbstract).Any()"); yield return(components.Get(_abstract).Any(), "Components.Get(abstract).Any()"); yield return(components.Get(typeof(IComponent)).Any(), "Components.Get(IComponent).Any()"); yield return(components.Get <TConcrete>().Count() == components.Get(typeof(TConcrete)).Count(), "Components.Get<TConcrete>().Count() == Components.Get(TConcrete).Count()"); yield return(components.Get <TConcrete>().Count() == entities.Count(entity => components.Has <TConcrete>(entity)), "Components.Get<TConcrete>().Count()"); yield return(components.Get <TConcrete>().Count() == model.Components.Count(pair => pair.Value.Contains(typeof(TConcrete))), "Components.Get<TConcrete>().Count() == model.Components"); yield return(components.Get(typeof(TConcrete)).Count() == entities.Count(entity => components.Has(entity, typeof(TConcrete))), "Components.Get(TConcrete).Count()"); yield return(components.Get(typeof(TConcrete)).Count() == model.Components.Count(pair => pair.Value.Contains(typeof(TConcrete))), "Components.Get(TConcrete).Count() == model.Components"); yield return(components.Get(_entity).Any(), "Components.Get(entity).Any()"); yield return(components.Get(_entity).OfType <TConcrete>().Any(), "Components.Get().OfType<TConcrete>().Any()"); yield return(components.Get(_entity).OfType <TAbstract>().Any(), "Components.Get().OfType<TAbstract>().Any()"); yield return(components.Get(_entity).OfType(_abstract).Any(), "Components.Get().OfType(abstract).Any()"); yield return(components.Get(_entity).OfType <IComponent>().Any(), "Components.Get().OfType<IComponent>().Any()"); yield return(components.Get <TConcrete>(_entity).Equals(_component), "Components.Get<TConcrete>() == component"); yield return(components.Get(_entity, typeof(TConcrete)).Equals(_component), "Components.Get(TConcrete) == component"); yield return(components.TryGet <TConcrete>(_entity, out _), "Components.TryGet<TConcrete>()"); yield return(components.TryGet <TAbstract>(_entity, out _), "Components.TryGet<TAbstract>()"); yield return(components.TryGet <IComponent>(_entity, out _), "Components.TryGet<IComponent>()"); yield return(components.TryGet(_entity, typeof(TConcrete), out _), "Components.TryGet(TConcrete)"); yield return(components.TryGet(_entity, typeof(TAbstract), out _), "Components.TryGet<T>(TAbstract)"); yield return(components.TryGet(_entity, _abstract, out _), "Components.TryGet<T>(abstract)"); yield return(components.TryGet(_entity, typeof(IComponent), out _), "Components.TryGet<T>(IComponent)"); yield return(components.TryGet(_entity, typeof(void), out _).Not(), "Components.TryGet<T>(void).Not()"); yield return(_onAdd.All(message => message.Entity == _entity && message.Component.Type.Is <TConcrete>()), "onAdd.All"); yield return(_onAddT.All(message => message.Entity == _entity), "onAddT.All"); if (_success) { yield return(components.State(_entity).HasAny(States.Enabled), "Components.State<T>()"); yield return(components.State <TConcrete>(_entity) == States.Enabled, "Components.State<T>()"); yield return(components.State(_entity, typeof(TConcrete)) == States.Enabled, "Components.State(Type)"); yield return(components.Enable <TConcrete>(_entity).Not(), "Components.Enable<T>()"); yield return(components.Enable(_entity, typeof(TConcrete)).Not(), "Components.Enable(Type)"); yield return(_onAdd.Length == 1, "onAdd.Length == 1"); yield return(_onAddT.Length == 1, "onAddT.Length == 1"); } else { yield return(_onAdd.Length == 0, "onAdd.Length == 0"); yield return(_onAddT.Length == 0, "onAddT.Length == 0"); } yield return(components.Set(_entity, (IComponent)_component).Not(), "Components.Set(Entity, component).Not()"); yield return(components.Set(_entity, _component).Not(), "Components.Set<TConcrete>(Entity, component).Not()"); yield return(components.Set(_entity, typeof(TConcrete)).Not(), "Components.Set(Entity, TConcrete).Not()"); yield return(components.Set <TConcrete>(_entity).Not(), "Components.Set<TConcrete>(Entity).Not()"); } }