本文整理汇总了C#中TestState.RemoveAllComponents方法的典型用法代码示例。如果您正苦于以下问题:C# TestState.RemoveAllComponents方法的具体用法?C# TestState.RemoveAllComponents怎么用?C# TestState.RemoveAllComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestState
的用法示例。
在下文中一共展示了TestState.RemoveAllComponents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例2: 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);
}