当前位置: 首页>>代码示例>>C#>>正文


C# TestState.AddComponent方法代码示例

本文整理汇总了C#中TestState.AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C# TestState.AddComponent方法的具体用法?C# TestState.AddComponent怎么用?C# TestState.AddComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestState的用法示例。


在下文中一共展示了TestState.AddComponent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldRemoveAllComponentsFromGameState

 public void ShouldRemoveAllComponentsFromGameState()
 {
     var state = new TestState();
     var fooComp1 = new FooComponent();
     var fooComp2 = new FooComponent();
     state.AddComponent(fooComp1);
     state.AddComponent(fooComp2);
     Assert.AreEqual(state.GetAllComponents().Count(), 2);
     state.RemoveAllComponents();
     Assert.IsEmpty(state.GetAllComponents());
 }
开发者ID:remy22,项目名称:TriEngine,代码行数:11,代码来源:GameStateTests.cs

示例2: ShouldAddComponentToGameState

 public void ShouldAddComponentToGameState()
 {
     var state = new TestState();
     Assert.False(state.HasComponent(typeof (FooComponent)));
     var comp = state.AddComponent(new FooComponent());
     Assert.True(state.HasComponent(comp));
 }
开发者ID:remy22,项目名称:TriEngine,代码行数:7,代码来源:GameStateTests.cs

示例3: ShouldHaveComponentOfType

 public void ShouldHaveComponentOfType()
 {
     var state = new TestState();
     var fooComp = new FooComponent();
     state.AddComponent(fooComp);
     Assert.True(state.HasComponent(typeof(FooComponent)));
     Assert.False(state.HasComponent(typeof(BarComponent)));
 }
开发者ID:remy22,项目名称:TriEngine,代码行数:8,代码来源:GameStateTests.cs

示例4: ShouldHaveComponentMatchingPredicate

 public void ShouldHaveComponentMatchingPredicate()
 {
     var state = new TestState();
     var fooComp = new FooComponent();
     state.AddComponent(fooComp);
     Assert.True(state.HasComponent(c => ((FooComponent)c).Test == "Foo"));
     Assert.False(state.HasComponent(c => ((FooComponent)c).Test == "Bar"));
 }
开发者ID:remy22,项目名称:TriEngine,代码行数:8,代码来源:GameStateTests.cs

示例5: ShouldRemoveAllComponentsMatchingPredicateFromGameState

        public void ShouldRemoveAllComponentsMatchingPredicateFromGameState()
        {
            var state = new TestState();
            var fooComp1 = new FooComponent();
            var fooComp2 = new FooComponent {Test = "NewFoo"};
            state.AddComponent(fooComp1);
            state.AddComponent(fooComp2);
            Assert.AreEqual(state.GetAllComponents().Count(), 2);

            // This is ok in this code, since we only have a FooComponent in the GameState
            // at the moment. In production code we should probably cast c to FooComponent
            // and make sure it's not null before checking the Test field.
            state.RemoveAllComponents(c => ((FooComponent)c).Test == "Foo");

            // The component should only have one element left, as we changed the value of
            // the Test field on one of the objects.
            Assert.AreEqual(state.GetAllComponents().Count(), 1);
        }
开发者ID:remy22,项目名称:TriEngine,代码行数:18,代码来源:GameStateTests.cs

示例6: ShouldOnlyHaveExactReferenceToComponent

 public void ShouldOnlyHaveExactReferenceToComponent()
 {
     var state = new TestState();
     var fooComp = new FooComponent();
     var fooComp2 = new FooComponent();
     state.AddComponent(fooComp);
     Assert.True(state.HasComponent(fooComp));
     Assert.False(state.HasComponent(fooComp2));
 }
开发者ID:remy22,项目名称:TriEngine,代码行数:9,代码来源:GameStateTests.cs

示例7: ShouldReturnComponentOfType

        public void ShouldReturnComponentOfType()
        {
            var state = new TestState();
            var fooComp = new FooComponent();
            var customFoo = new FooComponent { Test = "NewFoo" };
            state.AddComponent(fooComp);
            state.AddComponent(customFoo);

            Assert.IsInstanceOf<FooComponent>(state.GetComponent(typeof(FooComponent)));
        }
开发者ID:remy22,项目名称:TriEngine,代码行数:10,代码来源:GameStateTests.cs

示例8: ShouldReturnComponentMatchingPredicate

        public void ShouldReturnComponentMatchingPredicate()
        {
            var state = new TestState();
            var fooComp = new FooComponent();
            var customFoo = new FooComponent { Test = "NewFoo" };
            state.AddComponent(fooComp);
            state.AddComponent(customFoo);

            // We have to do some null checking, as we have both Foo and Bar components
            // in the game state.

            Assert.AreEqual(state.GetComponent(c =>
            {
                var cf = c as FooComponent;
                return cf != null && cf.Test == "NewFoo";
            }), customFoo);
        }
开发者ID:remy22,项目名称:TriEngine,代码行数:17,代码来源:GameStateTests.cs

示例9: ShouldReturnAllComponentsOfType

 public void ShouldReturnAllComponentsOfType()
 {
     var state = new TestState();
     var fooComp = new FooComponent();
     var customFoo = new FooComponent { Test = "NewFoo" };
     var barComp = new BarComponent();
     var customBar = new BarComponent { Test = "NewBar" };
     state.AddComponent(fooComp);
     state.AddComponent(customFoo);
     state.AddComponent(barComp);
     state.AddComponent(customBar);
     Assert.AreEqual(state.GetAllComponents(typeof(FooComponent)).Count(), 2);
 }
开发者ID:remy22,项目名称:TriEngine,代码行数:13,代码来源:GameStateTests.cs

示例10: ShouldReturnAllComponentsMatchingPredicate

        public void ShouldReturnAllComponentsMatchingPredicate()
        {
            var state = new TestState();
            var fooComp = new FooComponent();
            var customFoo = new FooComponent { Test = "NewFoo" };
            var barComp = new BarComponent();
            var customBar = new BarComponent { Test = "NewBar" };
            state.AddComponent(fooComp);
            state.AddComponent(customFoo);
            state.AddComponent(barComp);
            state.AddComponent(customBar);

            // We have to do some null checking, as we have both Foo and Bar components
            // in the game state.

            Assert.AreEqual(state.GetAllComponents(c =>
            {
                var f = c as FooComponent;
                return f != null && f.Test == "NewFoo";
            }).Count(), 1);

            Assert.IsEmpty(state.GetAllComponents(c =>
            {
                var f = c as FooComponent;
                return f != null && f.Test == "NewBar";
            }));
        }
开发者ID:remy22,项目名称:TriEngine,代码行数:27,代码来源:GameStateTests.cs

示例11: ShouldRemoveComponentFromGameState

 public void ShouldRemoveComponentFromGameState()
 {
     var state = new TestState();
     var fooComp = new FooComponent();
     state.AddComponent(fooComp);
     Assert.IsNotEmpty(state.GetAllComponents());
     state.RemoveComponent(fooComp);
     Assert.IsEmpty(state.GetAllComponents());
 }
开发者ID:remy22,项目名称:TriEngine,代码行数:9,代码来源:GameStateTests.cs


注:本文中的TestState.AddComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。