Esempio n. 1
0
        public void TestSaveLevel()
        {
            D2Level level;

            using (var stream = TestUtils.GetResourceStream("test.rl2"))
            {
                level = D2Level.CreateFromStream(stream);
            }

            // Write the level and then re-load it. We don't save the same way as DLE
            // so the output won't match.
            // So we need to compare against something we saved earlier.
            var memoryStream = new MemoryStream();

            level.WriteToStream(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);
            level = D2Level.CreateFromStream(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);

            // Now do the test
            var originalFileContents = memoryStream.ToArray();

            Assert.DoesNotThrow(() => level.WriteToStream(memoryStream));
            var resultingFileContents = memoryStream.ToArray();

            Assert.That(resultingFileContents, Is.EqualTo(originalFileContents));
        }
Esempio n. 2
0
        private void FillComboBoxes()
        {
            cmbDifficulty.Items.Clear();
            cmbDifficulty.Items.Add(new Item(LABEL_NORMAL, 0));
            cmbDifficulty.Items.Add(new Item(LABEL_NIGHTMARE, 1));
            cmbDifficulty.Items.Add(new Item(LABEL_HELL, 2));
            cmbDifficulty.SelectedIndex = AutoSplit.Difficulty;
            cmbDifficulty.Show();
            if (AutoSplit.IsDifficultyIgnored())
            {
                cmbDifficulty.Hide();
            }
            else
            {
                cmbDifficulty.SelectedIndex = AutoSplit.Difficulty;
            }

            cmbValue.Items.Clear();
            switch (AutoSplit.Type)
            {
            case AutoSplit.SplitType.CharLevel:
                for (int i = 1; i < 100; i++)
                {
                    cmbValue.Items.Add(new Item("" + i, i));
                }
                break;

            case AutoSplit.SplitType.Area:
                foreach (D2Level lvl in D2Level.getAll())
                {
                    if (lvl.id > 0)
                    {
                        cmbValue.Items.Add(new Item(lvl.name, lvl.id));
                    }
                }
                break;

            case AutoSplit.SplitType.Item:
                cmbValue.Items.Add(new Item(LABEL_HORADRIC_CUBE, (int)D2Data.ItemId.HORADRIC_CUBE));
                cmbValue.Items.Add(new Item(LABEL_HORADRIC_SHAFT, (int)D2Data.ItemId.HORADRIC_SHAFT));
                cmbValue.Items.Add(new Item(LABEL_HORADRIC_AMULET, (int)D2Data.ItemId.HORADRIC_AMULET));
                cmbValue.Items.Add(new Item(LABEL_KHALIMS_EYE, (int)D2Data.ItemId.KHALIM_EYE));
                cmbValue.Items.Add(new Item(LABEL_KHALIMS_HEART, (int)D2Data.ItemId.KHALIM_HEART));
                cmbValue.Items.Add(new Item(LABEL_KHALIMS_BRAIN, (int)D2Data.ItemId.KHALIM_BRAIN));
                break;

            case AutoSplit.SplitType.Quest:
                foreach (KeyValuePair <D2QuestHelper.Quest, D2QuestHelper.D2Quest> item in D2QuestHelper.Quests)
                {
                    cmbValue.Items.Add(new Item((item.Value.BossQuest ? "" : ("Act " + item.Value.Act + " - ")) + item.Value.CommonName, (int)item.Key));
                }
                break;

            case AutoSplit.SplitType.Special:
                cmbValue.Items.Add(new Item(LABEL_GAME_START, (int)AutoSplit.Special.GameStart));
                cmbValue.Items.Add(new Item(LABEL_CLEAR_100_PERCENT, (int)AutoSplit.Special.Clear100Percent));
                cmbValue.Items.Add(new Item(LABEL_CLEAR_100_PERCENT_ALL, (int)AutoSplit.Special.Clear100PercentAllDifficulties));
                break;
            }
        }
Esempio n. 3
0
 public Rl2Tests(D2Level level)
 {
     this.level = level;
 }