Esempio n. 1
0
        public void TestMyMagicCollectionCsvWrite()
        {
            var cards = new[] {
                new MagicBinderCard()
                {
                    RowId  = "row1",
                    CardId = "card id 1",
                    Grade  = MagicGrade.LightlyPlayed,
                },
                new MagicBinderCard()
                {
                    RowId         = "row2",
                    CardId        = "card id 2",
                    Grade         = MagicGrade.NearMint,
                    Language      = MagicLanguage.German,
                    QuantityTrade = 1,
                }
            }.ToList();

            var collection = new MagicBinder(cards)
            {
                Name = "My collection",
            };

            var targetFileName = Path.Combine(TestContext.DeploymentDirectory, "CsvTest " + Guid.NewGuid().ToString() + ".csv");
            var target         = new MyMagicCollectionCsv();

            target.WriteFile(targetFileName, collection);

            var referenceFile = GetType().Assembly.LoadEmbeddedResourceTextFile("TestMyMagicCollectionCsvWrite.csv");
            var writtenFile   = File.ReadAllText(targetFileName);

            Assert.AreEqual(referenceFile, writtenFile);
        }
Esempio n. 2
0
        public void WriteFile(string fileName)
        {
            if (_magicCollection == null)
            {
                return;
            }

            var collectionWriter = new MyMagicCollectionCsv();

            collectionWriter.WriteFile(fileName, _magicCollection);
            _fileName = fileName;

            // TODO: make this optional:
            var colWriter = new Coll2Writer(_notificationCenter);

            colWriter.Write(_fileName + ".coll2", _magicCollection.Cards);
        }