Beispiel #1
0
        public void CanWriteItems()
        {
            var items = importer.Read();

            using (var file = new TempFile()) {
                var exporter = new GDFileExporter(file.filename, IsExpansion1, ModName);
                exporter.Write(items);

                // Byte wise compare
                byte[] written = File.ReadAllBytes(file.filename);
                byte[] read    = File.ReadAllBytes(SourceFile);
                written.Length.Should().Be.EqualTo(read.Length);

                for (int i = 0; i < written.Length; i++)
                {
                    written[i].Should().Be.EqualTo(read[i]);
                }

                // TOOD: Is this proper? its read related testing..
                var verifiy = exporter.Read();
                verifiy.Count.Should().Be.EqualTo(items.Count);

                foreach (var item in verifiy)
                {
                    item.BaseRecord.Should().StartWith("records/");
                }
            }
        }
Beispiel #2
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            if (buttonExport.Enabled)
            {
                if (IsGdstashFormat)
                {
                    var io = new GDFileExporter(filename, false, string.Empty); // Params are not used for writing

                    GDTransferFile settings = cbItemSelection.SelectedItem as GDTransferFile;
                    if (settings == null)
                    {
                        var items = playerItemDao.ListAll();
                        io.Write(items);
                    }
                    else
                    {
                        var items = playerItemDao.ListAll()
                                    .Where(item => item.IsHardcore == settings.IsHardcore /* && item.IsExpansion1 == settings.IsExpansion1*/);

                        if (string.IsNullOrEmpty(settings.Mod))
                        {
                            io.Write(items.Where(item => string.IsNullOrEmpty(item.Mod)).ToList());
                        }
                        else
                        {
                            io.Write(items.Where(item => item.Mod == settings.Mod).ToList());
                        }
                    }
                }
                else
                {
                    var io    = new IAFileExporter(filename);
                    var items = playerItemDao.ListAll();
                    io.Write(items);
                }

                MessageBox.Show("Items Exported!", "Items exported!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }