Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions InfoBox/Context/InformationBoxScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public class InformationBoxScope : IDisposable
{
#region Attributes

// TODO: [P1.1] Replace static Stack with AsyncLocal<Stack<InformationBoxScope>> for thread-safety
// See TESTABILITY_ROADMAP.md - current implementation is not thread-safe for concurrent tests
// private static readonly AsyncLocal<Stack<InformationBoxScope>> _scopeStack = new AsyncLocal<Stack<InformationBoxScope>>();
// Also add IInformationBoxScope interface and TestScopeProvider for dependency injection in tests
/// <summary>
/// Stack of all scopes
/// </summary>
Expand Down
21 changes: 3 additions & 18 deletions InfoBox/Form/InformationBoxForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,9 @@ internal InformationBoxForm(string text,
InformationBoxSound sound = InformationBoxSound.Default)
{
this.InitializeComponent();
// TODO: [P0.2] Replace CreateGraphics with ITextMeasurement interface injection
// See TESTABILITY_ROADMAP.md - this prevents headless testing
this.measureGraphics = CreateGraphics();
this.measureGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

// TODO: [P1.3] Replace SystemFonts with ISystemResources interface injection
// See TESTABILITY_ROADMAP.md - this prevents testing without system fonts
// Apply default font for message boxes
this.Font = SystemFonts.MessageBoxFont;
this.messageText.Font = SystemFonts.MessageBoxFont;
Expand Down Expand Up @@ -646,8 +642,6 @@ internal InformationBoxResult Show(out CheckState state)
/// </summary>
private void PlaySound()
{
// TODO: [P1.3] Replace SystemSounds with ISystemResources.PlaySound(InformationBoxSound)
// See TESTABILITY_ROADMAP.md - this entire method logic should move to WindowsSystemResources
if (sound == InformationBoxSound.None)
{
return;
Expand Down Expand Up @@ -1007,8 +1001,6 @@ private void SetFocus()
/// </summary>
private void SetLayout()
{
// TODO: [P0.1] Extract this 110-line method to InformationBoxPresenter.CalculateLayout()
// See TESTABILITY_ROADMAP.md - this complex layout logic should be testable without WinForms
int totalHeight;
int totalWidth;

Expand Down Expand Up @@ -1068,8 +1060,6 @@ private void SetLayout()

totalHeight = Math.Max(iconHeight, textHeight) + BorderPadding * 2 + this.pnlBas.Height;

// TODO: [P1.3] Replace Screen.PrimaryScreen with ISystemResources.GetWorkingArea()
// See TESTABILITY_ROADMAP.md - hardcoded screen metrics prevent testing with different screen sizes
// Add a small space to avoid vertical scrollbar.
if (iconAndTextWidth > Screen.PrimaryScreen.WorkingArea.Width - 100)
{
Expand Down Expand Up @@ -1270,17 +1260,16 @@ private void SetText()
Screen currentScreen = Screen.FromControl(this);
int screenWidth = currentScreen.WorkingArea.Width;

this.messageText.Text = this.messageText.Text.Replace("\r\n", "\n");
this.messageText.Text = this.messageText.Text.Replace("\n", Environment.NewLine);

if (this.autoSizeMode == InformationBoxAutoSizeMode.FitToText)
{
this.messageText.WordWrap = false;
this.messageText.Size = TextRenderer.MeasureText(this.messageText.Text, this.messageText.Font, currentScreen.WorkingArea.Size, TextFormatFlags.TextBoxControl) + new Size(1, 1);
}
else
{
this.messageText.Text = this.messageText.Text.Replace("\r\n", "\n");
this.messageText.Text = this.messageText.Text.Replace("\n", Environment.NewLine);


if (this.autoSizeMode == InformationBoxAutoSizeMode.None)
{
this.messageText.WordWrap = true;
Expand Down Expand Up @@ -1342,8 +1331,6 @@ private void SetText()
/// </summary>
private void SetButtons()
{
// TODO: [P0.1] Extract button generation logic to InformationBoxPresenter.GetButtons()
// See TESTABILITY_ROADMAP.md - this logic should return List<ButtonDefinition> without WinForms dependencies
// Abort button
if (this.buttons == InformationBoxButtons.AbortRetryIgnore)
{
Expand Down Expand Up @@ -1699,8 +1686,6 @@ private void InformationBoxForm_KeyDown(object sender, KeyEventArgs e)
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void TmrAutoClose_Tick(object sender, EventArgs e)
{
// TODO: [P0.1] Extract this 115-line timer logic to InformationBoxPresenter.UpdateAutoClose(TimeSpan elapsed)
// See TESTABILITY_ROADMAP.md - this should be a pure function returning AutoCloseState without Timer dependencies
if (this.elapsedTime == this.autoClose.Seconds)
{
this.tmrAutoClose.Stop();
Expand Down
14 changes: 4 additions & 10 deletions InfoBox/InformationBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ namespace InfoBox
/// <summary>
/// Displays a message box that can contain text, buttons, and symbols that inform and instruct the user.
/// </summary>
#if !NET5_0_OR_GREATER
#if !NET5_0_OR_GREATER
[UIPermission(SecurityAction.Demand)]
#endif
#endif
public static class InformationBox
{
// TODO: [P1.2] Add factory pattern for testability
// See TESTABILITY_ROADMAP.md - Add IInformationBoxFactory and IInformationBoxDisplay interfaces
// internal static IInformationBoxFactory Factory { get; set; } = new InformationBoxFactory();
// This will allow tests to inject mock factories and test code that calls InformationBox.Show()

#region Show
#region Show

/// <summary>
/// Displays a message box with the specified text and parameters.
Expand Down Expand Up @@ -138,7 +133,6 @@ public static class InformationBox
/// <returns>One of the <see cref="InformationBoxResult"/> values.</returns>
public static InformationBoxResult Show(string text, params object[] parameters)
{
// TODO: [P1.2] Replace direct instantiation with Factory.Create(text, parameters).ShowModal()
return new InformationBoxForm(text, parameters).Show();
}

Expand Down Expand Up @@ -429,6 +423,6 @@ public static InformationBoxResult Show(string text,
style, autoClose, design, fontParameters, font, titleStyle, titleIcon, legacyButtons, legacyIcon, legacyDefaultButton, behavior, callback, opacity, parent, order, sound).Show(out checkBoxState);
}

#endregion Show
#endregion Show
}
}
Loading