예제 #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));
        }
예제 #2
0
 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;
 }
예제 #3
0
        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));
        }
예제 #4
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>());
        }
예제 #5
0
        public void Constructor_SetsCorrectType()
        {
            var tile = new Character();

            Assert.That(tile.Type, Is.EqualTo(XType.Character));
        }