Esempio n. 1
0
        public void WorldUpdatesAutoupdateables()
        {
            var tmxStream = FileStreams.SmallTmx();
            var tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream());

            TmxSerializer   serializer = new TmxSerializer();
            Map             map        = serializer.Deserialize(tmxStream);
            TestingToyWorld toyWorld   = new TestingToyWorld(map, tilesetTableStreamReader);

            toyWorld.SetRegister(new AutoupdateRegister());

            Mock <IAutoupdateableGameActor> mock1 = new Mock <IAutoupdateableGameActor>();
            Mock <IAutoupdateableGameActor> mock2 = new Mock <IAutoupdateableGameActor>();

            toyWorld.AutoupdateRegister.Register(mock1.Object, 1);
            toyWorld.AutoupdateRegister.Register(mock2.Object, 2);

            // Act
            toyWorld.Update();

            // Assert
            mock1.Verify(x => x.Update(It.IsAny <Atlas>(), It.IsAny <TilesetTable>()));
            mock2.Verify(x => x.Update(It.IsAny <Atlas>(), It.IsAny <TilesetTable>()), Times.Never());

            // Act
            toyWorld.Update();

            // Assert
            mock2.Verify(x => x.Update(It.IsAny <Atlas>(), It.IsAny <TilesetTable>()));
        }
        public TilesetTableTest()
        {
            var tilesetTableMemoryStream = FileStreams.TilesetTableStream();
            var tilesetTableStreamReader = new StreamReader(tilesetTableMemoryStream);

            tilesetTableStreamReader.DiscardBufferedData();
            tilesetTableMemoryStream.Position = 0;
            var tilesetTable = new TilesetTable(null, tilesetTableStreamReader);
        }
Esempio n. 3
0
 public GLRendererTestBase()
 {
     using (var tmxStream = FileStreams.FullTmxStream())
         using (var tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream()))
         {
             var gameSetup = new GameSetup(tmxStream, tilesetTableStreamReader);
             m_gameController = ControllerFactory.GetController(gameSetup);
             m_gameController.Init();
         }
 }
Esempio n. 4
0
        public ToyWorldTests()
        {
            Stream       tmxStream = FileStreams.SmallTmx();
            StreamReader tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream());

            TmxSerializer serializer = new TmxSerializer();
            Map           map        = serializer.Deserialize(tmxStream);

            m_world = new ToyWorld(map, tilesetTableStreamReader);
        }
Esempio n. 5
0
        public AtlasTests()
        {
            Stream       tmxStream = FileStreams.SmallPickupTmx();
            StreamReader tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream());

            TmxSerializer serializer = new TmxSerializer();
            Map           map        = serializer.Deserialize(tmxStream);
            ToyWorld      world      = new ToyWorld(map, tilesetTableStreamReader);

            m_atlas = world.Atlas;
        }
Esempio n. 6
0
        public GameControllerTestBase()
        {
            var tmxMemoryStream          = FileStreams.SmallTmx();
            var tilesetTableMemoryStream = FileStreams.TilesetTableStream();

            var tilesetTableStreamReader = new StreamReader(tilesetTableMemoryStream);

            var gameSetup = new GameSetup(tmxMemoryStream, tilesetTableStreamReader);

            GameController = GetController(gameSetup);

            GameController.Init();
        }
Esempio n. 7
0
        public MapLoaderTests()
        {
            // initiate streamReaders
            var tmxMemoryStream          = FileStreams.SmallTmx();
            var tilesetTableMemoryStream = FileStreams.TilesetTableStream();

            var tilesetTableStreamReader = new StreamReader(tilesetTableMemoryStream);

            var serializer = new TmxSerializer();
            Map map        = serializer.Deserialize(tmxMemoryStream);

            var tilesetTable = new TilesetTable(map, tilesetTableStreamReader);

            // create atlas
            m_atlas = MapLoader.LoadMap(map, tilesetTable, (GameActor actor) => { });
        }
Esempio n. 8
0
        public void AvatarLoosingEnergy()
        {
            Stream       tmxStream = FileStreams.SmallPickupTmx();
            StreamReader tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream());

            TmxSerializer serializer = new TmxSerializer();
            Map           map        = serializer.Deserialize(tmxStream);

            m_worldPickupWorld = new ToyWorld(map, tilesetTableStreamReader);

            m_eater = m_worldPickupWorld.GetAvatar(m_worldPickupWorld.GetAvatarsIds()[0]);

            // Act
            for (int i = 0; i < 100; i++)
            {
                m_eater.Update(m_worldPickupWorld.Atlas, It.IsAny <TilesetTable>());
            }

            // Assert
            Assert.True(m_eater.Energy < 1);
        }
Esempio n. 9
0
        public void AvatarCanPickUp()
        {
            Stream       tmxStream = FileStreams.SmallPickupTmx();
            StreamReader tilesetTableStreamReader = new StreamReader(FileStreams.TilesetTableStream());

            TmxSerializer serializer = new TmxSerializer();
            Map           map        = serializer.Deserialize(tmxStream);

            m_worldPickupWorld = new ToyWorld(map, tilesetTableStreamReader);

            m_avatarPickuper        = m_worldPickupWorld.GetAvatar(m_worldPickupWorld.GetAvatarsIds()[0]);
            m_avatarPickuper.PickUp = true;

            Assert.Equal(null, m_avatarPickuper.Tool);

            // Act
            m_avatarPickuper.Update(m_worldPickupWorld.Atlas, It.IsAny <TilesetTable>());

            // Assert
            Assert.IsType <Apple>(m_avatarPickuper.Tool);
            Assert.False(m_avatarPickuper.PickUp);
        }
Esempio n. 10
0
 public void WorldWithNullMapThrows()
 {
     Assert.Throws <ArgumentNullException>(() => new ToyWorld(null, new StreamReader(FileStreams.TilesetTableStream())));
 }