Example #1
0
        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));
        }
Example #2
0
        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>());
        }