Namespace: Snake
Assembly: Snake (in Snake.exe) Version: 1.1.1.0 (1.1.1)
Tests: Snake.Tests.SnakeGameTests
3 unit tests call Snake.Snake.Dispose
Assembly: Snake (in Snake.exe) Version: 1.1.1.0 (1.1.1)
Syntax
Implements
IDisposable DisposeRemarks
Examples
[Test, CloseAfterFirstFrame] public void QuitGracefullyDisposes() { var game = new Game(Resolve<Window>()); Assert.DoesNotThrow(game.CloseGame); }
[Test, CloseAfterFirstFrame] public void GoingBackToMenuDisposesOfSnake() { var game = new Game(Resolve<Window>()); game.StartGame(); AdvanceTimeAndUpdateEntities(); game.Reset(); var keyboard = Resolve<Keyboard>(); if (keyboard.GetType() != typeof(MockKeyboard)) return; //ncrunch: no coverage (This is for NOT ncrunch...) var mockKeyboard = (MockKeyboard)keyboard; mockKeyboard.SetKeyboardState(Key.N, State.Pressing); Assert.DoesNotThrow(() => AdvanceTimeAndUpdateEntities()); Assert.AreEqual(0, EntitiesRunner.Current.GetEntitiesOfType<Snake>().Count); }
[Test, CloseAfterFirstFrame] public void DisposeSnake() { var snake = new Snake(gridSize, Color.Green) { IsActive = false }; Assert.AreEqual(2, snake.Get<Body>().BodyParts.Count); snake.Dispose(); Assert.Throws<Entity.ComponentNotFound>(() => snake.Get<Body>()); }
See Also