public void LoadTest()
        {
            string tmpFilename = Path.GetTempFileName();

            MysteryCreator mysteryCreator1 = new MysteryCreator();

            mysteryCreator1.NumberOfColumns = 7;
            mysteryCreator1.NumberOfRows    = 7;
            mysteryCreator1.NumberOfShips   = 12;
            Mystery mystery1 = mysteryCreator1.Create();

            SaveLoadService.Save(mystery1, tmpFilename);

            MysteryCreator mysteryCreator2 = new MysteryCreator();

            mysteryCreator2.NumberOfColumns = 2;
            mysteryCreator2.NumberOfRows    = 2;
            mysteryCreator2.NumberOfShips   = 1;
            Mystery mystery2 = mysteryCreator2.Create();

            mystery2 = SaveLoadService.Load(mystery2, tmpFilename);
            Assert.IsTrue(mystery2.FieldList.Count == mystery1.FieldList.Count && mystery1.ShipList.Count == mystery2.ShipList.Count);
            if (File.Exists(tmpFilename))
            {
                File.Delete(tmpFilename);
            }
        }
        public void CreateTest()
        {
            MysteryCreator mysteryCreator = new MysteryCreator();

            mysteryCreator.NumberOfColumns = 7;
            mysteryCreator.NumberOfRows    = 7;
            mysteryCreator.NumberOfShips   = 12;
            Mystery mystery = mysteryCreator.Create();

            Assert.IsTrue(mystery != null);
            Assert.IsTrue(mystery.FieldList.Count == 49 && mystery.FieldList.Where(f => f.IsShipField == true).ToList().Count == 12);
        }
        public void ExportSolutionTest()
        {
            string tmpFilename = Path.GetTempFileName();

            MysteryCreator mysteryCreator = new MysteryCreator();

            mysteryCreator.NumberOfColumns = 7;
            mysteryCreator.NumberOfRows    = 7;
            mysteryCreator.NumberOfShips   = 12;
            Mystery mystery = mysteryCreator.Create();

            ExportService.ExportSolution(mystery, tmpFilename);

            if (File.Exists(tmpFilename))
            {
                Assert.IsTrue(true);
                File.Delete(tmpFilename);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
示例#4
0
 public void GenerateMystery(object parameter)
 {
     try
     {
         PlayingFieldViewModel playingFieldViewModel = new PlayingFieldViewModel(_mysteryCreator.Create());
         MainWindow            mainWindow            = MainWindow.GetSingelton();
         mainWindow.Show();
         mainWindow.ShowPlayingField(playingFieldViewModel);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erstellung vom Rätsel Fehlgeschlagen", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }