public void Save(ref Board board, string levelName, LevelObjective objective) { export = new LevelExporter(); Level level = null; GameObject levelObj = GameObject.Find("Level"); if (levelObj != null) { level = levelObj.GetComponent <Level>(); } export.Save(ref board, ref level, levelName, -1, objective); }
public void TestReadWriteData() { var gridEditorSettingsForExport = Substitute.For <IGridEditorSettings>(); var gridEditorSettingsForImport = Substitute.For <IGridEditorSettings>(); LevelSummary expectedLevelSummary = new LevelSummary(59, "the level name"); for (int i = 0; i < 10; i++) { expectedLevelSummary.BallData.Add(CreateRandomBallData()); } gridEditorSettingsForExport.GetExportData().Returns(expectedLevelSummary); LevelSummary actualLevelSummary = null; gridEditorSettingsForImport .When(e => e.SetLevelData(Arg.Any <LevelSummary>())) .Do(x => actualLevelSummary = x.Arg <LevelSummary>()); var levelExporter = new LevelExporter(gridEditorSettingsForExport); var levelImporter = new LevelImporter(gridEditorSettingsForImport); levelExporter.Export(); var expectedFile = GameConstants.Levels.RelativeResourcePath + "level-" + expectedLevelSummary.OrdinalNumber + ".bin"; FileAssert.Exists(expectedFile); var successfullyImported = levelImporter.Import(expectedFile); Assert.True(successfullyImported); Assert.NotNull(actualLevelSummary); Assert.AreEqual(expectedLevelSummary.LevelNumber, actualLevelSummary.LevelNumber); Assert.AreEqual(expectedLevelSummary.OrdinalNumber, actualLevelSummary.OrdinalNumber); CollectionAssert.AreEquivalent(expectedLevelSummary.BallData, actualLevelSummary.BallData); }