public void CorrectAnimationGetsAddedToStore() { var animationStore = default(IAnimationStore); var eventHandler = default(BlocksFoundEventHandler); var fakeGameManager = default(IGameManager); var blocks = default(IEnumerable<Block>); "Given I have an empty animation store and a blocks found event handler".Context(() => { animationStore = new SingleAnimationStore(); fakeGameManager = A.Fake<IGameManager>(); eventHandler = new BlocksFoundEventHandler(animationStore, A.Fake<IBoard>(), fakeGameManager); blocks = new[]{ new Block(new BoardCoordinate[]{}), }; }); "When I handle the blocks found event" .Do(() => eventHandler.Handle(new BlocksFoundEvent(blocks))); "Then 1 item should be in the animation store".Observation( () => animationStore.GetCurrentAnimations().Count().ShouldEqual(1)); "Then the item in the animation store should be a blocks found animation" .Observation(() => animationStore.GetCurrentAnimations().First().ShouldBeOfType<BlocksFoundAnimation>()); "Then the blocks found method should be called on the game manager" .Observation(() => A.CallTo(() => fakeGameManager.BlockFound(A<IEnumerable<Block>>.Ignored)).MustHaveHappened()); }
public void CanRemoveAnAnimationToTheAnimationStore() { var animationStore = default(SingleAnimationStore); var result = default(IEnumerable<IAnimation>); "Given I have added an animation and then removed an animation to the animation store".Context(() => { animationStore = new SingleAnimationStore(); IAnimation animation = A.Fake<IAnimation>(); animationStore.Add(animation); animationStore.Remove(animation); }); "When I remove the animation".Do(() => result = animationStore.GetCurrentAnimations()); "Then 0 animations should be returned".Observation(() => result.Count().ShouldEqual(0)); }
public void CanAddAnAnimationToTheAnimationStore() { var animationStore = default(SingleAnimationStore); var result = default (IEnumerable<IAnimation>); var animation = default(IAnimation); "Given I have added an animation to the animation store".Context(() => { animationStore = new SingleAnimationStore(); animation = A.Fake<IAnimation>(); animationStore.Add(animation); }); "When I get the current animation items".Do(() => result = animationStore.GetCurrentAnimations()); "Then 1 animation should be returned".Observation(() => result.Count().ShouldEqual(1)); "Then the instance returned should be the same".Observation( () => result.First().ShouldBeTheSameAs(animation)); }
public void CorrectAnimationGetsAddedToStore() { var animationStore = default(IAnimationStore); var eventHandler = default(RotatedRightEventHandler); var fakeGameManager = default(IGameManager); "Given I have an empty animation store and a rotated right event handler".Context(() => { fakeGameManager = A.Fake<IGameManager>(); animationStore = new SingleAnimationStore(); eventHandler = new RotatedRightEventHandler(animationStore, A.Fake<IBoard>(), fakeGameManager); }); "When I handle the rotated right event".Do(() => eventHandler.Handle(new RotatedRightEvent{BoardCoordinates = new BoardCoordinate[]{}})); "Then 1 item should be in the animation store".Observation( () => animationStore.GetCurrentAnimations().Count().ShouldEqual(1)); "Then the item in the animation store should be a rotate right animation".Observation( () => animationStore.GetCurrentAnimations().First().ShouldBeOfType<RotateRightAnimation>()); "Then the rotation made method on the game manager should be called" .Observation(() => A.CallTo(() => fakeGameManager.RotationMade()).MustHaveHappened()); }