コード例 #1
0
        public void Parse_TmxFileNoTranslationUnits_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser   = new TmxParser();
            TmxFile           expected = MockObjects.VALID_en_TmxFile;

            // Act
            TmxFile result = parser.ParseFile(MockObjects.NO_TRANSLATION_UNITS_TmxFilePath);

            // Assert
            // -- Assert FileInfo
            Assert.AreEqual(MockObjects.NO_TRANSLATION_UNITS_TmxFilePath, result.FileInfo);
            // -- Assert Language code
            Assert.AreEqual("Unkown", result.LanguageCode);
            // -- Assert Data
            // ---- Assert version
            Assert.AreEqual(expected.Data.Version, result.Data.Version);
            // ---- Assert header
            Assert.AreEqual(expected.Data.Header.CreationToolVersion, result.Data.Header.CreationToolVersion);
            Assert.AreEqual(expected.Data.Header.DataType, result.Data.Header.DataType);
            Assert.AreEqual(expected.Data.Header.SegmentType, result.Data.Header.SegmentType);
            Assert.AreEqual(expected.Data.Header.AdminLanguage, result.Data.Header.AdminLanguage);
            Assert.AreEqual(expected.Data.Header.SourceLanguage, result.Data.Header.SourceLanguage);
            Assert.AreEqual(expected.Data.Header.OriginalTranslationMemoryFormat, result.Data.Header.OriginalTranslationMemoryFormat);
            Assert.AreEqual(expected.Data.Header.CreationTool, result.Data.Header.CreationTool);
            // ---- Assert body
            // ------ Assert TranslationUnits
            Assert.AreEqual(0, result.Data.Body.TranslationUnits.Count);
        }
コード例 #2
0
    public void LevelLoad(string level)
    {
        LevelReset();
        m_brickGO.SetActive(true);
        TextAsset m_textAsset = Resources.Load("Levels/" + level) as TextAsset;

        if (m_textAsset == null)
        {
            Debug.LogErrorFormat("File not found {0}", level);
            return;
        }
        else
        {
            Debug.Log("Loading level " + level);
        }
        TmxParser tmx = new TmxParser();

        tmx.ParseFile(m_textAsset.text);

        for (int j = 0; j < tmx.m_height; j++)
        {
            for (int i = 0; i < tmx.m_width; i++)
            {
                int brick_id   = tmx.m_brickData [j * tmx.m_width + i];
                int powerup_id = tmx.m_powerupData [j * tmx.m_width + i];
                if (brick_id != 0)
                {
                    AddBrick(i, j, brick_id, powerup_id);
                }
            }
        }
        m_brickGO.SetActive(false);
        m_powerupGO.SetActive(false);
        //tmx.Dump();
    }
コード例 #3
0
        public void Parse_InvalidTmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser = new TmxParser();

            // Act
            TmxFile result = parser.ParseFile(MockObjects.INVALID_TmxFilePath);

            // Assert
            Assert.IsNull(result);
        }
コード例 #4
0
        public void Parse_EmptyTmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser = new TmxParser();

            // Act
            TmxFile result = parser.ParseFile(MockObjects.EMPTY_TmxFilePath);

            // Assert
            Assert.IsNull(result);
        }
コード例 #5
0
        public void Parse_NonExistTmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser = new TmxParser();

            // Act
            TmxFile result = parser.ParseFile(MockObjects.NonEXIST_TmxFilePath);

            // Assert
            Assert.IsNull(result);
        }
コード例 #6
0
        public void Parse_Valid_pseudo_TmxFile_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser   = new TmxParser();
            TmxFile           expected = MockObjects.VALID_pseudo_TmxFile;

            // Act
            TmxFile result = parser.ParseFile(MockObjects.VALID_pseudo_TmxFilePath);

            // Assert
            // -- Assert FileInfo
            Assert.AreEqual(expected.FileInfo, result.FileInfo);
            // -- Assert Language code
            Assert.AreEqual(expected.LanguageCode, result.LanguageCode);
            Assert.AreNotEqual("Unkown", result.LanguageCode);
            // -- Assert Data
            // ---- Assert version
            Assert.AreEqual(expected.Data.Version, result.Data.Version);
            // ---- Assert header
            Assert.AreEqual(expected.Data.Header.CreationToolVersion, result.Data.Header.CreationToolVersion);
            Assert.AreEqual(expected.Data.Header.DataType, result.Data.Header.DataType);
            Assert.AreEqual(expected.Data.Header.SegmentType, result.Data.Header.SegmentType);
            Assert.AreEqual(expected.Data.Header.AdminLanguage, result.Data.Header.AdminLanguage);
            Assert.AreEqual(expected.Data.Header.SourceLanguage, result.Data.Header.SourceLanguage);
            Assert.AreEqual(expected.Data.Header.OriginalTranslationMemoryFormat, result.Data.Header.OriginalTranslationMemoryFormat);
            Assert.AreEqual(expected.Data.Header.CreationTool, result.Data.Header.CreationTool);
            // ---- Assert body
            // ------ Assert TranslationUnits
            foreach (TranslationUnit expectedTU in expected.Data.Body.TranslationUnits)
            {
                TranslationUnit unit = result.Data.Body.TranslationUnits
                                       .First <TranslationUnit>(
                    tu => tu.TranslationUnitId == expectedTU.TranslationUnitId
                    );

                Assert.IsNotNull(unit);
                Assert.AreEqual(expectedTU.TranslationUnitId, unit.TranslationUnitId);

                // ------ Assert TranslationUnitVariant
                foreach (TranslationUnitVariant expectedTUV in expectedTU.TranslationUnitVariants)
                {
                    TranslationUnitVariant unitVar = unit.TranslationUnitVariants
                                                     .First <TranslationUnitVariant>(
                        tuv => tuv.Segment == expectedTUV.Segment
                        );

                    Assert.IsNotNull(unitVar);
                    Assert.AreEqual(expectedTUV.Language, unitVar.Language);
                    Assert.AreEqual(expectedTUV.Segment, unitVar.Segment);
                }
            }
        }
コード例 #7
0
        public void Parse_TmxFileNoTranslationUnitVarients_To_TmxFileObject_Test()
        {
            // Assign
            AbstractTmxParser parser   = new TmxParser();
            TmxFile           expected = MockObjects.VALID_en_TmxFile;

            // Act
            TmxFile result = parser.ParseFile(MockObjects.NO_TRANSLATION_UNITS_VARIENTS_TmxFilePath);

            // Assert
            // -- Assert FileInfo
            Assert.AreEqual(MockObjects.NO_TRANSLATION_UNITS_VARIENTS_TmxFilePath, result.FileInfo);
            // -- Assert Language code
            Assert.AreEqual("Unkown", result.LanguageCode);
            // -- Assert Data
            // ---- Assert version
            Assert.AreEqual(expected.Data.Version, result.Data.Version);
            // ---- Assert header
            Assert.AreEqual(expected.Data.Header.CreationToolVersion, result.Data.Header.CreationToolVersion);
            Assert.AreEqual(expected.Data.Header.DataType, result.Data.Header.DataType);
            Assert.AreEqual(expected.Data.Header.SegmentType, result.Data.Header.SegmentType);
            Assert.AreEqual(expected.Data.Header.AdminLanguage, result.Data.Header.AdminLanguage);
            Assert.AreEqual(expected.Data.Header.SourceLanguage, result.Data.Header.SourceLanguage);
            Assert.AreEqual(expected.Data.Header.OriginalTranslationMemoryFormat, result.Data.Header.OriginalTranslationMemoryFormat);
            Assert.AreEqual(expected.Data.Header.CreationTool, result.Data.Header.CreationTool);
            // ---- Assert body
            // ------ Assert TranslationUnits
            foreach (TranslationUnit expectedTU in expected.Data.Body.TranslationUnits)
            {
                TranslationUnit unit = result.Data.Body.TranslationUnits
                                       .First <TranslationUnit>(
                    tu => tu.TranslationUnitId == expectedTU.TranslationUnitId
                    );

                Assert.IsNotNull(unit);
                Assert.AreEqual(expectedTU.TranslationUnitId, unit.TranslationUnitId);

                // ------ Assert TranslationUnitVariant
                Assert.AreEqual(0, unit.TranslationUnitVariants.Count);
            }
        }