Пример #1
0
        public void Custom2daReturnsValidValues()
        {
            string twoDimArray =
                @"2DA V2.0

    LABEL    TESTSTR      TESTINT          TESTFLOAT
0   Test0    ""Test 0""   0                0.0f 
1   Test1    ""Test 1""   0x1              1.0f
2   Test2    ""Test 2""   0x00000002       2.0f";

            string resourceName = "testtemp.2da";

            ResourceManager.WriteTempResource(resourceName, StringHelper.Cp1252Encoding.GetBytes(twoDimArray));
            createdTempResources.Add(resourceName);

            TwoDimArray array = NwGameTables.GetTable(resourceName);

            Assert.That(array.RowCount, Is.EqualTo(3));
            Assert.That(array.ColumnCount, Is.EqualTo(4));
            Assert.That(array.Columns, Is.EquivalentTo(new[] { "label", "teststr", "testint", "testfloat" }));

            Assert.That(array.GetString(0, "TESTSTR"), Is.EqualTo("Test 0"));
            Assert.That(array.GetString(1, "TESTSTR"), Is.EqualTo("Test 1"));
            Assert.That(array.GetString(2, "TESTSTR"), Is.EqualTo("Test 2"));
            Assert.That(array.GetInt(0, "TESTINT"), Is.EqualTo(0));
            Assert.That(array.GetInt(1, "TESTINT"), Is.EqualTo(0x1));
            Assert.That(array.GetInt(2, "TESTINT"), Is.EqualTo(0x00000002));
            Assert.That(array.GetFloat(0, "TESTFLOAT"), Is.EqualTo(0f));
            Assert.That(array.GetFloat(1, "TESTFLOAT"), Is.EqualTo(1f));
            Assert.That(array.GetFloat(2, "TESTFLOAT"), Is.EqualTo(2f));
        }