public void TestReserialize() { var deck = DeckSerializer.Deserialize(DeckString); var reserialized = DeckSerializer.Serialize(deck, false); Assert.AreEqual(DeckString, reserialized); }
public static void SavePlayerCreatedDecksToFile() { List <string> deckStrings = CurrentDecks.Select(x => DeckSerializer.Serialize(x, true)).ToList(); string path = Path.Combine(Config.SavedDataFolder(), Config.SavedDecksFile()); File.WriteAllLines(path, deckStrings); Log.Info("Successfully saved player created decks to file."); }
public void DeserializeWithComments() { var deck = DeckSerializer.Deserialize(FullDeckString); Assert.AreEqual("Warrior123", deck.Name); Assert.AreEqual(30, deck.GetCards().Values.Sum()); var serialized = DeckSerializer.Serialize(deck, false); Assert.AreEqual(DeckString, serialized); }
public void TestSerializerCommentsDefaults() { var deck = DeckSerializer.Deserialize(DeckString); var commented = DeckSerializer.Serialize(deck, true); var lines = commented.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual("### Warrior Deck", lines[0]); Assert.AreEqual("# Class: Warrior", lines[1]); Assert.AreEqual("# Format: Standard", lines[2]); }
public void TestSerializerComments() { var deck = DeckSerializer.Deserialize(DeckString); deck.Name = "Warrior123"; deck.ZodiacYear = ZodiacYear.MAMMOTH; var commented = DeckSerializer.Serialize(deck, true); var lines = commented.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual("### Warrior123", lines[0]); Assert.AreEqual("# Class: Warrior", lines[1]); Assert.AreEqual("# Format: Standard", lines[2]); Assert.AreEqual("# Year of the Mammoth", lines[3]); }
/// <summary> /// Generates a deckcode for the deck that was last played during the game /// </summary> /// <returns></returns> public string GenerateDeckCode() { // Extract deckcode string deckcode; try { deckcode = DeckSerializer.Serialize(this, false); } catch (Exception exc) { Log.Error(exc); throw new Exception("Exception while serializing played deck"); } // And return it Hearthstone_Deck_Tracker.Utility.Logging.Log.Info(deckcode); return(deckcode); }