コード例 #1
0
        public bool GetContainsComponent(ComponentId componentId)
        {
            if (componentId == null)
            {
                throw new ArgumentNullException(nameof(componentId));
            }

            return(_components.Contains(componentId));
        }
コード例 #2
0
 public bool GetContainsComponent(ComponentId componentId)
 {
     return(_components.Contains(componentId));
 }
コード例 #3
0
        public void ContainsBasic()
        {
            // Create and add a component
            var component = new Component1();

            _componentCollection.Add(component);

            // Component1 qualifies as both of these types, so both should be true.
            Assert.True(_componentCollection.Contains <Component1>());
            Assert.True(_componentCollection.Contains <ComponentBase>());

            // Component1 is NOT this type, so this is false
            Assert.False(_componentCollection.Contains <Component2>());

            // Create and add a component of a different type
            var component2 = new Component2();

            _componentCollection.Add(component2);

            // Now all 3 should be true
            Assert.True(_componentCollection.Contains <Component1>());
            Assert.True(_componentCollection.Contains <ComponentBase>());
            Assert.True(_componentCollection.Contains <Component2>());

            _componentCollection.Remove(component);

            Assert.False(_componentCollection.Contains <Component1>());
            Assert.True(_componentCollection.Contains <ComponentBase>()); // Component2 qualifies
            Assert.True(_componentCollection.Contains <Component2>());
        }