示例#1
0
        public void ScenarioAnswers()
        {
            var bundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "scenario"));

            if (bundle == null)
            {
                Assert.Fail();
            }

            var csvDataTable = new CSVDataTable();

            csvDataTable.ReadFromTextAsset(bundle.LoadAsset <TextAsset>("scenario"));

            var scenarionStorage = new ScenarioStorage();

            scenarionStorage.RegisterHeader(csvDataTable.Header);
            var forTest = new List <string>();

            for (var i = 0; i < csvDataTable.RowCount; i++)
            {
                string answer;
                for (var j = 1; j < GameParams.MaxAnswerButton; j++)
                {
                    answer = csvDataTable.GetRow(i)[scenarionStorage.Header["answer_" + j + "_out"]];
                    if (answer != string.Empty && !forTest.Contains(answer))
                    {
                        forTest.Add(answer);
                    }
                }
                answer = csvDataTable.GetRow(i)[scenarionStorage.Header["next"]];
                if (answer != string.Empty && answer != "end" && !forTest.Contains(answer))
                {
                    forTest.Add(answer);
                }
            }

            foreach (var item in forTest)
            {
                var flag = false;
                for (var i = 0; i < csvDataTable.RowCount; i++)
                {
                    if (csvDataTable.GetRow(i)[scenarionStorage.Header["key"]] == item)
                    {
                        flag = true;
                    }
                }

                if (!flag)
                {
                    Assert.Fail();
                }
            }
            Assert.Pass();
        }
示例#2
0
        private void ParseScenario()
        {
            var csvDataTable = new CSVDataTable();

            csvDataTable.ReadFromTextAsset(GetScenario());

            _scenarionStorage = new ScenarioStorage();
            _scenarionStorage.RegisterHeader(csvDataTable.Header);
            for (var i = 0; i < csvDataTable.RowCount; i++)
            {
                _scenarionStorage.RegisterRow(csvDataTable.GetRow(i));
            }
        }