Example #1
0
        /// <summary>
        /// Tests the save method using the specified file path.
        /// </summary>
        private void TestSaveMethod(string filePath)
        {
            StringTableFile stringTableFile = new StringTableFile();
            stringTableFile.Load(filePath);

            MemoryStream savedStream = new MemoryStream();
            stringTableFile.Save(savedStream);
            savedStream.Seek(0, SeekOrigin.Begin);

            StringTableFile savedStringTableFile = new StringTableFile();
            savedStringTableFile.Load(savedStream);
            savedStream.Close();

            Assert.AreEqual(stringTableFile.TableType, stringTableFile.TableType, "Table types do not match");
            Assert.AreEqual(stringTableFile.RowCount, stringTableFile.RowCount, "Row counts do not match");

            for (int i = 0; i < stringTableFile.RowCount; i++) {
                for (int j = 0; j < stringTableFile.LanguageCount; j++) {
                    StringTableLanguage language = (StringTableLanguage)j;

                    Assert.AreEqual(stringTableFile[i].GetText(language), savedStringTableFile[i].GetText(language), "Text values do not match");

                    if (stringTableFile.TableType == StringTableType.Item || stringTableFile.TableType == StringTableType.Quest) {
                        Assert.AreEqual(stringTableFile[i].GetDescription(language), savedStringTableFile[i].GetDescription(language), "Description values do not match");

                        if (stringTableFile.TableType == StringTableType.Quest) {
                            Assert.AreEqual(stringTableFile[i].GetStartMessage(language), savedStringTableFile[i].GetStartMessage(language), "Start message values do not match");
                            Assert.AreEqual(stringTableFile[i].GetEndMessage(language), savedStringTableFile[i].GetEndMessage(language), "End message values do not match");
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Tests the load method using the specified file path and row count.
        /// </summary>
        private void TestLoadMethod(string filePath, int rowCount)
        {
            Stream stream = File.OpenRead(filePath);

            stream.Seek(0, SeekOrigin.End);
            long fileSize = stream.Position;
            stream.Seek(0, SeekOrigin.Begin);

            StringTableFile stringTableFile = new StringTableFile();
            stringTableFile.Load(stream);

            long streamPosition = stream.Position;
            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
            Assert.AreEqual(rowCount, stringTableFile.RowCount, "Incorrect row count");
        }