Skip to content

Commit

Permalink
update timer tests to handle first manual reset not required
Browse files Browse the repository at this point in the history
  • Loading branch information
pjmagee committed Nov 24, 2024
1 parent bbdf6db commit 2694457
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
21 changes: 16 additions & 5 deletions src/Dota2Helper.Tests/DotaTimerViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,29 @@ public void WhenTimer_IsManualReset_And_ReachesEnd_Then_RequiresManualReset()
TimeSpan time = TimeSpan.FromSeconds(0);
TimeSpan maxTime = timer.Time;

Assert.IsTrue(timer.IsFirstManualTimer);

while (time < maxTime)
{
timer.Update(time);
time = time.Add(TimeSpan.FromSeconds(1));
}

// Assert
Assert.IsTrue(timer.IsResetRequired);
Assert.IsTrue(timer.TimeRemaining == timer.Time);
// Assert first manual reset is not required
Assert.IsFalse(timer.IsResetRequired);
Assert.IsFalse(timer.IsFirstManualTimer);

timer.ResetCommand.Execute(null);
time = TimeSpan.FromSeconds(10);
maxTime = maxTime.Add(timer.Time);

Assert.IsFalse(timer.IsResetRequired);
while (time < maxTime)
{
timer.Update(time);
time = time.Add(TimeSpan.FromSeconds(1));
}

// Assert second manual reset is required
Assert.IsFalse(timer.IsFirstManualTimer);
Assert.IsTrue(timer.IsResetRequired);
}
}
16 changes: 15 additions & 1 deletion src/Dota2Helper/Controls/GuideTabContent.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<TextBlock TextWrapping="Wrap" Width="750">
The application can play audio files when a timer triggers. You can set the audio file for each timer from the Timers tab.
The application will play the audio file when the timer triggers, the default audio files are located in the audio folder.
The audio files were created using Google Text-to-Speech.
The audio files were created using OpenAI TTS and are free to use. You can also use your own audio mp3 or wav files.
</TextBlock>
</StackPanel>

Expand All @@ -114,6 +114,20 @@
</TextBlock>
</StackPanel>

<!-- Timer Mode -->
<StackPanel Orientation="Vertical" HorizontalAlignment="Left">
<TextBlock Margin="0 5" FontSize="18" FontWeight="Bold">
Timer mode
</TextBlock>
<TextBlock TextWrapping="Wrap" Width="750">
Timer mode is used to determine how the application will handle game time.
There are three modes, Game, Demo and Auto:
In Game mode, the application will use the game time from the GSI data.
In Demo mode, the application will use a fake time.
In Auto mode, the application will use the game time from the GSI data if it is available, otherwise, it will use the fake time.
</TextBlock>
</StackPanel>

</StackPanel>
</ScrollViewer>
</UserControl>
9 changes: 5 additions & 4 deletions src/Dota2Helper/Controls/IntegrationTabContent.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
<StackPanel Margin="0 10" Orientation="Vertical">

<StackPanel Margin="5" Orientation="Vertical" Spacing="5">
<Grid Margin="5" RowDefinitions="*,*,*,*" ColumnDefinitions="100,Auto" VerticalAlignment="Center">
<Label Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">Timer Mode</Label>

<Grid Margin="5" RowDefinitions="*,*,*,*" ColumnDefinitions="Auto,Auto" VerticalAlignment="Center">
<Label Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">Timer mode:</Label>
<ComboBox Grid.Row="0" Grid.Column="1"
SelectedItem="{Binding SelectedTimerMode, Mode=TwoWay}"
ItemsSource="{Binding TimerModes, Mode=OneTime}"
Width="150">
<ComboBox.ItemTemplate>
<DataTemplate DataType="timers:TimerStrategy">
<TextBlock Text="{Binding Name}" ToolTip.Tip="{Binding ToolTip}" />
<TextBlock Text="{Binding Name}" ToolTip.Tip="{Binding ToolTip}" HorizontalAlignment="Stretch" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Demo Muted</Label>
<Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Mute demo timers:</Label>
<CheckBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" IsChecked="{Binding DemoMuted, Mode=TwoWay}" />

</Grid>
Expand Down

0 comments on commit 2694457

Please sign in to comment.