예제 #1
0
        public void GivenAComponentWasAddedToActor_TheComponentActorShouldBeTheActorItWasAddedTo()
        {
            var actor     = new Actor();
            var component = new SampleActorComponent();

            actor.AttachComponent(component);

            component.GetActor().Should().Be(actor);
        }
예제 #2
0
        public void GivenAComponentWasRemovedFromActor_TheComponentActorShouldBeNull()
        {
            var actor     = new Actor();
            var component = new SampleActorComponent();

            actor.AttachComponent(component);
            actor.RemoveComponent(component);

            component.GetActor().Should().BeNull();
        }
예제 #3
0
        public void GivenAComponentWasRemoved_ThenActorShouldNotHaveTheRemovedComponent()
        {
            var actor     = new Actor();
            var component = new SampleActorComponent();

            actor.AttachComponent(component);
            actor.RemoveComponent(component);

            actor.Components.Should().HaveCount(0);
        }
예제 #4
0
        public void GivenAComponentWasAdded_ThenActorShouldHaveTheAddedComponent()
        {
            var actor     = new Actor();
            var component = new SampleActorComponent();

            actor.AttachComponent(component);

            actor.Components.Should().HaveCount(1);
            actor.Components.FirstOrDefault().Should().Be(component);
        }
예제 #5
0
        public void CallingTickOnActorShouldCallTickOnEveryOfItsComponents()
        {
            var actor      = new Actor();
            var component1 = new SampleActorComponent();
            var component2 = new SampleActorComponent();

            actor.AttachComponent(component1);
            actor.AttachComponent(component2);

            actor.Tick(12);
            component1.TickCount.Should().Be(1);
            component2.TickCount.Should().Be(1);
            component1.LastTickDeltaMs.Should().Be(12);
            component2.LastTickDeltaMs.Should().Be(12);

            actor.Tick(16);
            component1.TickCount.Should().Be(2);
            component2.TickCount.Should().Be(2);
            component1.LastTickDeltaMs.Should().Be(16);
            component2.LastTickDeltaMs.Should().Be(16);
        }