private void ShowSession(IMainForm mainForm, ICountdownTime countdownTime, TimerProgress more) { if (_counter.Value().LessThan(SessionsToLongBreak).Not()) { return; } _shortBreakAction.Act(mainForm, countdownTime, more); }
private void ShowLongBreak(IMainForm mainForm, ICountdownTime countdownTime, TimerProgress more) { if (_counter.Value().LessThan(SessionsToLongBreak)) { return; } _counter.Restart(); _longBreakAction.Act(mainForm, countdownTime, more); }
private void Timer_Tick(object sender, EventArgs e) { Progress.Increment(1); if (Progress.Value == Progress.Maximum) { TimerProgress.Stop(); MessageBox.Show("Время вышло!"); Reset(); } }
public void ShouldActGivenMore() { //Arrange TimerProgress timeProgress = TimerProgress.More; MockMainForm mockMainForm = new MockMainForm.Builder().Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_GuardAgainstNoMore subject = new CountdownTimerUpdateAction_GuardAgainstNoMore(nextAction); //Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); //Assert nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); }
public void ShouldAct() { // Arrange TimerProgress timeProgress = TimerProgress.Last; MockMainForm mockMainForm = new MockMainForm.Builder().Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_TimerRunning subject = new PrivateCtor <CountdownTimerUpdateAction_TimerRunning>(nextAction); // Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); // Assert nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); }
public void ShouldAct() { // Arrange TimerProgress timeProgress = TimerProgress.Last; MockMainForm mockMainForm = new MockMainForm.Builder().Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); ShortBreakTimerUpdateAction_TimerFinished subject = new ShortBreakTimerUpdateAction_TimerFinished(nextAction); // Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); // Assert nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); }
public void ShouldAct() { // Arrange TimerProgress timeProgress = TimerProgress.Last; MockMainForm mockMainForm = new MockMainForm.Builder().ToTop().Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_FormToTop subject = new CountdownTimerUpdateAction_FormToTop(nextAction); // Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); // Assert nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); mockMainForm.AssertToTopInvoked(); }
public void ShouldColorForeColor() { //Arrange TimerProgress timeProgress = TimerProgress.Last; MockWriteColor mockWriteColor = new MockWriteColor.Builder().Write().Build(); MockMainForm mockMainForm = new MockMainForm.Builder().CountDownForeColorWriter(mockWriteColor).Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_DefaultForeColor subject = new CountdownTimerUpdateAction_DefaultForeColor(nextAction); //Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); //Assert //mockWriteColor.AssertWriteInvokedWithCustom();//TODO: Make sure black is written nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); }
public void ShouldShowShortBreakMessage() { // Arrange TimerProgress timeProgress = TimerProgress.Last; MockMainForm mockMainForm = new MockMainForm.Builder().ShowAlert().Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_ShowShortBreakOver subject = new CountdownTimerUpdateAction_ShowShortBreakOver(nextAction); // Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); // Assert mockMainForm.AssertShowAlertInvokedWithCustom(text => ((string)text).Should().Be("Short Break Over!")); nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); }
private void Start_Click(object sender, EventArgs e) { Start.Click -= Start_Click; Start.Click += Stop_Click; Start.Text = "Stop"; Restart.Visible = true; Random rand = new Random(); buttons = new Button[sizeSqr, sizeSqr]; Box.Controls.Clear(); int koef = 290 / sizeSqr; for (int i = 0; i < sizeSqr; i++) { for (int j = 0; j < sizeSqr; j++) { buttons[i, j] = new Button(); buttons[i, j].Location = new Point(koef * i, koef * j); buttons[i, j].Size = new Size(koef, koef); buttons[i, j].TabIndex = 10; buttons[i, j].UseVisualStyleBackColor = true; buttons[i, j].Click += PlayButton_Click; int min = (int)Min.Value; int max = (int)Max.Value; int res = rand.Next(min, max); while (values.IndexOf(res) != -1) { res = rand.Next(min, max); } values.Add(res); buttons[i, j].Text = res.ToString(); buttons[i, j].Visible = true; Box.Controls.Add(buttons[i, j]); } } values.Sort(); TimerProgress.Start(); ControlsParam.Enabled = false; Progress.Maximum = (int)TrackTime.Value; }
public void ShouldWriteFormattedText() { // Arrange TimerProgress timeProgress = TimerProgress.Last; MockWriteText mockWriteText = new MockWriteText.Builder().Write().Build(); MockMainForm mockMainForm = new MockMainForm.Builder().CountDownTextWriter(mockWriteText).Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Remaining(new Seconds(1)).Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_RemainingTime subject = new CountdownTimerUpdateAction_RemainingTime(nextAction); //// Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); // Assert mockWriteText.AssertWriteInvokedWithCustom(text => ((string)text).Should().Be("00:01")); nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); }
public void ShouldAct() { // Arrange TimerProgress timeProgress = TimerProgress.Last; MockEnabled mockEnabled = new MockEnabled.Builder().Enable().Build(); MockMainForm mockMainForm = new MockMainForm.Builder().ShortBreakStartEnabled(mockEnabled).Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_EnableShortBreakStart subject = new CountdownTimerUpdateAction_EnableShortBreakStart(nextAction); // Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); // Assert nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); mockMainForm.AssertShortBreakStartEnabledInvoked(); mockEnabled.AssertEnableInvoked(); }
public void ShouldAct() { // Arrange TimerProgress timeProgress = TimerProgress.Last; MockVisibility mockVisibility = new MockVisibility.Builder().Hide().Build(); MockMainForm mockMainForm = new MockMainForm.Builder().LongBreakStartVisibility(mockVisibility).Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build(); CountdownTimerUpdateAction_HideLongBreakStart subject = new CountdownTimerUpdateAction_HideLongBreakStart(nextAction); // Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); // Assert nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress); mockMainForm.LongBreakStartVisibility(); mockVisibility.AssertHideInvoked(); }
public void ShouldNotActGivenLast() { //Arrange TimerProgress timeProgress = TimerProgress.Last; MockMainForm mockMainForm = new MockMainForm.Builder().Build(); MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build(); MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Build(); CountdownTimerUpdateAction_GuardAgainstNoMore subject = new CountdownTimerUpdateAction_GuardAgainstNoMore(nextAction); //Act subject.Act(mockMainForm, mockCountdownTime, timeProgress); //Assert try { nextAction.Act(null, null, null); Assert.Fail("Exception expected"); } catch (TestException ignored) { } }
private void Reset() { currentStep = -1; values.Clear(); Progress.Value = 0; for (int i = 0; i < sizeSqr; i++) { for (int j = 0; j < sizeSqr; j++) { buttons[i, j].Visible = false; } } ControlsParam.Enabled = true; Start.Enabled = true; TimerProgress.Stop(); Start.Click += Start_Click; Start.Click -= Stop_Click; Start.Text = "Start"; Restart.Visible = false; }
/// <summary> /// Handles the Click event of the BtnDecode control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private async void BtnDecode_ClickAsync(object sender, EventArgs e) { if (BtnDecodeReady() == false) { return; } int charLength = (int)StegDecode.GetCharactersToRead(); string password = TextBoxAesPassword.Text; // Set up progress report TimerProgress.Start(); BtnDecode.Enabled = false; ProgressBarDecode.Maximum = charLength * 8; ProgressBarDecode.Value = 0; string message = await Task.Run(() => StegDecode.ReadImage()); if (CheckBoxAes.Checked) { message = Crypto.Decrypt(message, password); if (message == null) { TimerProgress.Stop(); BtnDecode.Enabled = true; MessageBox.Show(String.Format("{0} is not a valid hash type", Settings.Hash)); return; } } if (CheckBoxBase64.Checked) { message = Converter.Base64ToAscii(message); } TextOutput.Text = message; BtnDecode.Enabled = true; ProgressBarDecode.Value = ProgressBarDecode.Maximum; TimerProgress.Stop(); }
/// <summary> /// Handles the Click event of the BtnEncode control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private async void BtnEncodeAsync_ClickAsync(object sender, EventArgs e) { if (!BtnEncodeReady()) { return; } string message = TextMessage.Text; if (CheckBoxBase64.Checked) { message = Converter.AsciiToBase64(message); } if (CheckBoxAes.Checked) { message = Crypto.Encrypt(message, TextBoxAesKey.Text); if (message == null) { MessageBox.Show(String.Format("{0} is not a valid hash type", Settings.Hash)); return; } } BtnEncode.Enabled = false; // Set up progress report TimerProgress.Start(); ProgressBarEncode.Maximum = StegEncode.MaxCharacters * 8; ProgressBarEncode.Value = 0; Task tEncode = new Task(() => StegEncode.CreateImage(message, StegEncode.OutputFile)); tEncode.Start(); await Task.WhenAll(tEncode); BtnEncode.Enabled = true; ProgressBarEncode.Value = ProgressBarEncode.Maximum; TimerProgress.Stop(); }
public void Act(IMainForm mainForm, ICountdownTime countdownTime, TimerProgress more) { _finished.Act(mainForm, countdownTime, more); _running.Act(mainForm, countdownTime, more); }
public void TriggerElapsed(ICountdownTime countdownTime, TimerProgress isMore) { //TODO: Looks like a "MockEvent" is gonna be needed TimerEvent.Invoke(countdownTime, isMore); }
public void AssertInvokeInvokedWith(TimerProgress progress) => _invoke.AssertInvokedWith(progress);
public void Act(IMainForm mainForm, ICountdownTime countdownTime, TimerProgress more) { _counter.Increment(); ShowSession(mainForm, countdownTime, more); ShowLongBreak(mainForm, countdownTime, more); }
public void Act(IMainForm mainForm, ICountdownTime countdownTime, TimerProgress more) { }
private void TimerOnTimerEvent(ICountdownTime countdowntime, TimerProgress ismore) => _updateAction.Act(_mainForm, countdowntime, ismore);
public void SetRestClock(TimerProgress clock) { restClock = clock; restClock.ResetTime(timeToFreeze); }
public void Act(IMainForm mainForm, ICountdownTime countdownTime, TimerProgress more) => _act.Invoke(new Tuple <IMainForm, ICountdownTime, TimerProgress>(mainForm, countdownTime, more));
public void Invoke(TimerProgress progress) => _invoke.Invoke(progress);
public void AssertActInvokedWith(IMainForm mainForm, ICountdownTime countdownTime, TimerProgress more) => _act.AssertInvokedWith(new Tuple <IMainForm, ICountdownTime, TimerProgress>(mainForm, countdownTime, more));