Ejemplo n.º 1
0
        private static void DeserializeCompileAndLoad <T>(string file, Action <T> doAsserts)
        {
            var result = Deserialize(file, doAsserts);

            var xnbStream = new MemoryStream();

#if XNA
            // In MS XNA the ContentCompiler is completely internal, so we need
            // to use just a little reflection to get access to what we need.
            const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
            var ctor          = typeof(ContentCompiler).GetConstructors(flags)[0];
            var compiler      = (ContentCompiler)ctor.Invoke(null);
            var compileMethod = typeof(ContentCompiler).GetMethod("Compile", flags);
            compileMethod.Invoke(compiler, new object[] { xnbStream, result, TargetPlatform.Windows, GraphicsProfile.Reach,
                                                          false, Directory.GetCurrentDirectory(), "referenceRelocationPath" });
#else
            var compiler = new ContentCompiler();
            compiler.Compile(xnbStream, result, TargetPlatform.Windows, GraphicsProfile.Reach,
                             false, "rootDirectory", "referenceRelocationPath");
#endif

            var content = new TestContentManager(xnbStream);
            var loaded  = content.Load <T>("Whatever");

            doAsserts(loaded);
        }
Ejemplo n.º 2
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _goomba         = new Goomba(0, 0, _level, _contentManager);
     _level.ToAddGameObject(_goomba);
     _level.UpdateLevel();
 }
Ejemplo n.º 3
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _mario          = new Mario(0, 0, _level, _contentManager);
     _level.ToAddGameObject(_mario);
     _level.UpdateLevel();
 }
Ejemplo n.º 4
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _mysteryBlock   = new MysteryBlock(0, 0, typeof(Coin), _level, _contentManager);
     _level.ToAddGameObject(_mysteryBlock);
     _level.UpdateLevel();
 }
Ejemplo n.º 5
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _Mushroom       = new Mushroom(0, 0, _level, _contentManager);
     _level.ToAddGameObject(_Mushroom);
     _level.UpdateLevel();
 }
Ejemplo n.º 6
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _fallingSpike   = new FallingSpike(0, 0, _level, _contentManager);
     _level.ToAddGameObject(_fallingSpike);
     _level.UpdateLevel();
 }
Ejemplo n.º 7
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _shell          = new Shell(0, 0, _level, _contentManager);
     _level.ToAddGameObject(_shell);
     _level.UpdateLevel();
 }
Ejemplo n.º 8
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _koopa          = new Koopa(0, 0, _level, _contentManager);
     _level.ToAddGameObject(_koopa);
     _level.UpdateLevel();
 }
Ejemplo n.º 9
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _floor          = new TransFloor(3, 3, 3, 3, _level, _contentManager);
     _level.ToAddGameObject(_floor);
     _level.UpdateLevel();
     _spriteBatch = new SpriteBatch(new TestGraphicsDeviceService().GraphicsDevice);
 }
Ejemplo n.º 10
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _mario          = new Mario(3, 3, _level, _contentManager);
     _coin           = new Coin(1, 1, _level, _contentManager);
     _level.ToAddGameObject(_mario);
     _level.ToAddGameObject(_coin);
     _level.UpdateLevel();
 }
Ejemplo n.º 11
0
        public void ReadAllLines()
        {
            var       file      = Path.Combine(TestContentManager.GetContentPath(), "text.txt");
            var       encoding  = Encoding.Default;
            const int takeLines = 3;
            var       lines     = File.ReadAllLines(file, encoding).Take(takeLines);

            var streamParser = new LineTextParser(UnitLineParser.Instance);
            int linesTaken   = 0;
            var lineStream   = Observable.Using(() => new StreamReader(file, encoding),
                                                reader => streamParser.ExtractWords(reader).Do(line => linesTaken++).Take(takeLines));
            var lines2 = lineStream.ToList().Wait();

            Assert.That(lines2, Is.EquivalentTo(lines));
            Assert.That(linesTaken, Is.LessThanOrEqualTo(takeLines));
        }
Ejemplo n.º 12
0
 void CompileAndLoadAssets <T>(T data, Action <T> validation)
 {
     foreach (var platform in Platforms)
     {
         foreach (var gfxProfile in GraphicsProfiles)
         {
             foreach (var compress in CompressContents)
             {
                 using (var xnbStream = new MemoryStream())
                 {
                     Compiler.Compile(xnbStream, data, platform, gfxProfile, compress, "", "");
                     using (var content = new TestContentManager(xnbStream))
                     {
                         var result = content.Load <T>("foo");
                         validation(result);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _cloudBlock     = new CloudBlock(1, 1, _level, _contentManager);
 }
Ejemplo n.º 14
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _stoneBlock     = new StoneBlock(1, 1, _level, _contentManager);
 }
Ejemplo n.º 15
0
 public LineStreamParserTests()
 {
     largeContentPath = TestContentManager.PrepareLargeTextFile();
 }
Ejemplo n.º 16
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _muncher        = new Muncher(1, 1, _level, _contentManager);
 }
 public void Init()
 {
     _gameObjectFactory = new GameObjectFactory();
     _contentManager    = new TestContentManager();
     _level             = new Level();
 }
Ejemplo n.º 18
0
 protected static IList <string> CopyContentFilesTo(string pattern, string path)
 {
     return(TestContentManager.CopyContentFilesTo(pattern, path));
 }