public void SendFillIncorrectParameters_ThrowException(int height, int width, int mineCount, string expected) { IMinefield minefield = MinefieldTestHelper.CreateDefaultMinefield(); SettingsItem settings = CreateCustomSettings(height, width, mineCount); minefield.SetGameSettings(settings); var ex = Assert.Catch <Exception>(() => minefield.Fill()); StringAssert.Contains(expected.ToUpper(), ex.Message.ToUpper()); }
public void FillMinefield_StateToNotStarted() { IMinefield minefield = SetMineToCenter(); SettingsItem settings = CreateCustomSettings(10, 10, 1); minefield.SetGameSettings(settings); minefield.Cells[0][0].Open(); minefield.Fill(); Assert.AreEqual(FieldState.NotStarted, minefield.State); }
public void GameRestart_FlagsCountReset() { IMinefield minefield = SetMineToCenter(); SettingsItem settings = CreateCustomSettings(10, 10, 1); minefield.SetGameSettings(settings); minefield.Cells[0][0].SetFlag(); minefield.Cells[1][1].SetFlag(); minefield.Fill(); Assert.AreEqual(0, minefield.FlagsCount); }
public static IMinefield DefaultMinefield(int fieldHeightCell, int fieldWidthCell) { IMinefield field = MinefieldTestHelper.CreateDefaultMinefield(); SettingsItem settings = new SettingsItem() { Height = fieldHeightCell, Width = fieldWidthCell, MineCount = DefaultMineCount }; field.SetGameSettings(settings); field.Fill(); return(field); }
protected Game(ISettingsManager settings, IRecords records, IMinefield gameField, IGetRecordsmanNameProvider getRecordsmanNameProvider = null) { Settings = settings; Settings.OnCurrentGameChanged += Settings_OnCurrentGameChanged; Records = records; Timer = new GameTimer(); GameField = gameField; GameField.SetGameSettings(Settings.CurrentSettings); GameField.Fill(); GameField.OnStateChanged += GameField_OnStateChanged; this.getRecordsmanNameProvider = getRecordsmanNameProvider; }