Ejemplo n.º 1
0
        public void Initialize_BuilderIsCalled()
        {
            var parameters = new DungeonParameters();
            var mapBuilder = Substitute.For<IMapBuilder>();

            var processor = new Processor(
                mapBuilder,
                Substitute.For<IDungeonPopulator>(),
                Substitute.For<IMapPainter>());
            processor.Initialize(parameters);

            mapBuilder.Received(1).Build(parameters);
        }
Ejemplo n.º 2
0
        public void Initialize_CorrectDungeonIsSet()
        {
            var dungeon = new FakeDungeon();
            var mapBuilder = Substitute.For<IMapBuilder>();
            mapBuilder.Build(Arg.Any<DungeonParameters>())
                .Returns(dungeon);

            var processor = new Processor(
                mapBuilder,
                Substitute.For<IDungeonPopulator>(),
                Substitute.For<IMapPainter>());
            processor.Initialize(new DungeonParameters());

            Assert.That(processor.Dungeon,
                Has.Property(nameof(Dungeon.Size)).EqualTo(dungeon.Size));
        }
Ejemplo n.º 3
0
        public void Initialize_PopulatorIsCalled()
        {
            var parameters = new DungeonParameters();
            var dungeon = new FakeDungeon();
            var mapBuilder = Substitute.For<IMapBuilder>();
            mapBuilder.Build(parameters).Returns(dungeon);
            var populator = Substitute.For<IDungeonPopulator>();

            var processor = new Processor(
                mapBuilder,
                populator,
                Substitute.For<IMapPainter>());
            processor.Initialize(parameters);

            populator.Received(1).Fill(
                Arg.Is<IGameDungeon>(d => d.Size == dungeon.Size));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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>());
        }