Snake Dispose Method Delta Engine Documentation

Namespace: Snake
Assembly: Snake (in Snake.exe) Version: 1.1.1.0 (1.1.1)
Syntax

public override void Dispose()

Implements

IDisposable Dispose 
Remarks

Tests: Snake.Tests.SnakeGameTests
Examples

3 unit tests call Snake.Snake.Dispose
[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