public void Process_PainterDrawMapIsCalledWithCorrectMapImage() { var parameters = new DungeonParameters(); var dungeon = new FakeDungeon(5, 4); var mapBuilder = Substitute.For<IMapBuilder>(); mapBuilder.Build(parameters).Returns(dungeon); var populator = Substitute.For<IDungeonPopulator>(); var character = new Character { Location = new Point(1, 1) }; populator.WhenForAnyArgs(it => it.Fill(Arg.Any<IGameDungeon>())) .Do(d => { d.Arg<IGameDungeon>().Character = character; }); var painter = Substitute.For<IMapPainter>(); var processor = new Processor( mapBuilder, populator, painter); processor.Initialize(parameters); processor.Process(GameAction.None); painter.Received(1).DrawMap(Arg.Is<MapImage>(d => d.Width == dungeon.Width && d.Height == dungeon.Height && d[1, 1].Type == XType.Character)); }
private static void CreateCharacter(IGameDungeon dungeon) { var character = new Character(); var upstairs = dungeon.Single(c => c.Type == XType.StairsUp); character.Location = upstairs.Location; dungeon.Character = character; }
public void Character_GetReturnsSameValue_AsWasSet() { var dungeon = new Dungeon(1, 1); var expected = new Character(); dungeon.Character = expected; Assert.That(dungeon.Character, Is.SameAs(expected)); }
public void Process_PainterDrawMessageIsCalled() { var parameters = new DungeonParameters(); var dungeon = new FakeDungeon(5, 4); var mapBuilder = Substitute.For<IMapBuilder>(); mapBuilder.Build(parameters).Returns(dungeon); var populator = Substitute.For<IDungeonPopulator>(); var character = new Character { Location = new Point(1, 1) }; populator.WhenForAnyArgs(it => it.Fill(Arg.Any<IGameDungeon>())) .Do(d => { d.Arg<IGameDungeon>().Character = character; }); var painter = Substitute.For<IMapPainter>(); var processor = new Processor( mapBuilder, populator, painter); processor.Initialize(parameters); processor.Process(GameAction.None); ////TODO test precise message painter.Received(1).DrawMessage(Arg.Any<GameMessage>()); }
public void Constructor_SetsCorrectType() { var tile = new Character(); Assert.That(tile.Type, Is.EqualTo(XType.Character)); }