public void AddBehaviourTest() { _behaviours.ClearAll(); var behaviour = new Behaviour(); behaviour.NameId = "some"; Assert.That(_behaviours.Add(behaviour)); Assert.That(_behaviours.Add(behaviour) == false); }
/// <summary> /// Initializes a new instance of the <see cref="Behaviour"/> class. /// </summary> /// <param name="nameId">The name identifier.</param> /// <param name="collection">The collection.</param> /// <exception cref="Crystal.Behaviour.BehaviourCollectionNullException"></exception> /// <exception cref="Crystal.Behaviour.BehaviourAlreadyExistsInCollectionException"></exception> public Behaviour(string nameId, IBehaviourCollection collection) : base(collection?.Options?.Considerations) { if (collection == null) { throw new BehaviourCollectionNullException(); } NameId = nameId; _collection = collection; Initialize(); if (_collection.Add(this) == false) { throw new BehaviourAlreadyExistsInCollectionException(nameId); } }