public void PackTest()
        {
            const string excelFile = "Cards/Cards.xls";
            const string outFile   = excelFile + ".dataset";

            ExcelDataSetPacker.PackExcelToDataSet(excelFile, outFile);
            DataSet set = ExcelDataSetPacker.ReadDataset(outFile);

            Assert.NotNull(set);
            Assert.True(set.Tables.Count > 0);

            File.Delete(outFile);
        }
Exemple #2
0
        public void PackTest()
        {
            string xlsFileName     = Path.Combine("Cards", "Test.xls");
            string xlsFile         = Path.Combine(Application.streamingAssetsPath, xlsFileName);
            string dataSetFileName = Path.Combine("Cards", "Test.xls.dataset");
            string dataSetFile     = Path.Combine(Application.streamingAssetsPath, dataSetFileName);

            if (!File.Exists(xlsFile))
            {
                File.Copy("Assets\\TouhouHeartStone\\Tests\\Resources\\Cards.xls", xlsFile);
            }

            ExcelDataSetPacker.PackExcelToDataSet(xlsFile, dataSetFile);
            DataSet set = ExcelDataSetPacker.ReadDataset(dataSetFile);

            Assert.NotNull(set);
            Assert.True(set.Tables.Count > 0);

            File.Delete(dataSetFile);
            File.Delete(xlsFile);
        }
        public IEnumerator loadSkinsTest_Android()
        {
            var go = new GameObject(nameof(CardManager));

            go.AddComponent <ResourceManager>();
            CardManager cm = go.AddComponent <CardManager>();

            string xlsFile         = Path.Combine(Application.streamingAssetsPath, "Cards", "Test.xls");
            string dataSetFileName = Path.Combine("Cards", "Test.xls.dataset");
            string dataSetFile     = Path.Combine(Application.streamingAssetsPath, dataSetFileName);
            string pictureFile     = Path.Combine(Application.streamingAssetsPath, "测试图片.jpg");

            safeCopy("Assets\\TouhouHeartStone\\Tests\\Resources\\Cards.xls", xlsFile);
            safeCopy("Assets\\TouhouHeartStone\\Tests\\Resources\\测试图片.jpg", pictureFile);
            ExcelDataSetPacker.PackExcelToDataSet(xlsFile, dataSetFile);

            var task = cm.loadSkins(dataSetFileName, new PlatformCompability(RuntimePlatform.Android));

            yield return(new WaitUntil(() => task.IsCompleted));

            var skins = task.Result;

            Assert.NotNull(skins);
            var existingSkins = skins.Where(c => c.id == ExistsCardID);

            Assert.True(existingSkins.Count() > 0);

            var skin = existingSkins.First();

            Assert.AreEqual(skin.name, "测试卡牌");
            Assert.AreEqual(skin.desc, "");

            File.Delete(xlsFile);
            File.Delete(pictureFile);
            File.Delete(dataSetFile);
        }
        public IEnumerator loadCardsTest_Android()
        {
            var go = new GameObject(nameof(CardManager));

            go.AddComponent <ResourceManager>();
            CardManager cm = go.AddComponent <CardManager>();

            string xlsFile         = Path.Combine(Application.streamingAssetsPath, "Cards", "Test.xls");
            string dataSetFileName = Path.Combine("Cards", "Test.xls.dataset");
            string dataSetFile     = Path.Combine(Application.streamingAssetsPath, dataSetFileName);

            safeCopy("Assets\\TouhouHeartStone\\Tests\\Resources\\Cards.xls", xlsFile);
            ExcelDataSetPacker.PackExcelToDataSet(xlsFile, dataSetFile);

            var task = cm.loadCards(dataSetFileName, new PlatformCompability(RuntimePlatform.Android));

            yield return(new WaitUntil(() => task.IsCompleted));

            var cards = task.Result;

            Assert.NotNull(cards);
            var existingCards = cards.Where(c => c.id == ExistsCardID);

            Assert.True(existingCards.Count() > 0);

            var card = existingCards.First();

            Assert.AreEqual(card.id, ExistsCardID);
            Assert.AreEqual(card.type, "Master");
            Assert.AreEqual(card.getCost(), 0);
            Assert.AreEqual(card.getAttack(), 0);
            Assert.AreEqual(card.getLife(), 30);

            File.Delete(xlsFile);
            File.Delete(dataSetFile);
        }