public void Should_MapFromStream_Correctly_WithAllProps() { var game = converter.ConvertFromStream(stream)[1]; Assert.AreEqual("A Deck", game.Deck.Name); Assert.AreEqual(new Version(1, 0), game.DeckVersion); Assert.AreEqual(PlayerClass.WARLOCK, game.PlayerClass); Assert.AreEqual(GameMode.RANKED, game.Mode); Assert.AreEqual(GameFormat.STANDARD, game.Format); Assert.AreEqual(Region.EU, game.Region); Assert.AreEqual(12, game.Rank); Assert.AreEqual(new DateTime(2015, 01, 25, 19, 14, 36), game.StartTime); Assert.AreEqual(new DateTime(), game.EndTime); Assert.IsTrue(game.PlayerGotCoin); Assert.AreEqual(PlayerClass.HUNTER, game.OpponentClass); Assert.AreEqual("后海大白鲨", game.OpponentName); Assert.AreEqual(5, game.Turns); Assert.AreEqual(6, game.Minutes); Assert.AreEqual(GameResult.LOSS, game.Result); Assert.IsFalse(game.WasConceded); Assert.AreEqual("Some notes", game.Note.Text); Assert.AreEqual("Face", game.Note.Archetype); Assert.AreEqual("11000000-0000-0000-0000-000000000022", game.Id.ToString()); }
public static async Task <bool> Import(IStatsConverter converter, string file) { try { return(await Task.Run(() => { // create backup before any importing Backup.CreateBackup("BackupStatsConv"); // import from file using (var fs = new FileStream(file, FileMode.Open)) { var games = converter.ConvertFromStream(fs); StatsConverter.Data.AddGames(games); return true; } })); } catch (Exception e) { StatsConverter.Logger.Error(e); return(false); } }