Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Drawing;
using System.Windows.Forms.ButtonInternal;

namespace System.Windows.Forms.Tests;

public class RadioButtonFlatAdapterTests
{
[WinFormsFact]
public void PaintUp_AppearanceButton_CallsButtonFlatAdapterPaintUp()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = true
};

RadioButtonFlatAdapter adapter = new(control);
using Bitmap bitmap = new(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintUp(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintUp_AppearanceNormal_PaintsCorrectly()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = true
};

RadioButtonFlatAdapter adapter = new(control);
using Bitmap bitmap = new(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintUp(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintDown_AppearanceButton_CallsButtonFlatAdapterPaintDown()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = false
};

RadioButtonFlatAdapter adapter = new(control);
using Bitmap bitmap = new(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintDown(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeFalse();
}

[WinFormsFact]
public void PaintDown_AppearanceNormal_PaintsCorrectly()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = false
};

RadioButtonFlatAdapter adapter = new(control);
using Bitmap bitmap = new(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintDown(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeFalse();
}

[WinFormsFact]
public void PaintOver_AppearanceButton_CallsButtonFlatAdapterPaintOver()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = true
};

RadioButtonFlatAdapter adapter = new(control);
using Bitmap bitmap = new(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintOver(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintOver_AppearanceNormal_PaintsCorrectly()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = false
};

RadioButtonFlatAdapter adapter = new(control);
using Bitmap bitmap = new(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintOver(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Drawing;
using System.Windows.Forms.ButtonInternal;

namespace System.Windows.Forms.Tests;

public class RadioButtonPopupAdapterTests
{
[WinFormsFact]
public void PaintUp_AppearanceButton_CallsButtonPopupAdapterPaintUp()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = true
};

RadioButtonPopupAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintUp(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintUp_AppearanceNormal_PaintsCorrectly()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = true
};

RadioButtonPopupAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintUp(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintOver_AppearanceButton_CallsButtonPopupAdapterPaintOver()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = false
};

RadioButtonPopupAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintOver(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeFalse();
}

[WinFormsFact]
public void PaintOver_AppearanceNormal_PaintsCorrectly()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = false
};

RadioButtonPopupAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintOver(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeFalse();
}

[WinFormsFact]
public void PaintDown_AppearanceButton_CallsButtonPopupAdapterPaintDown()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = true
};

RadioButtonPopupAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintDown(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintDown_AppearanceNormal_PaintsCorrectly()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = false
};

RadioButtonPopupAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintDown(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Drawing;
using System.Windows.Forms.ButtonInternal;

namespace System.Windows.Forms.Tests;

public class RadioButtonStandardAdapterTests
{
[WinFormsFact]
public void PaintUp_AppearanceButton_CallsButtonAdapterPaintUp()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = true
};

RadioButtonStandardAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintUp(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintUp_AppearanceNormal_PaintsCorrectly()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = true
};

RadioButtonStandardAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintUp(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintDown_AppearanceButton_CallsButtonAdapterPaintDown()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = false
};

RadioButtonStandardAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintDown(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeFalse();
}

[WinFormsFact]
public void PaintDown_AppearanceNormal_CallsPaintUp()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = false
};

RadioButtonStandardAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintDown(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeFalse();
}

[WinFormsFact]
public void PaintOver_AppearanceButton_CallsButtonAdapterPaintOver()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Button,
Checked = true
};

RadioButtonStandardAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintOver(e, CheckState.Checked);

control.Appearance.Should().Be(Appearance.Button);
control.Checked.Should().BeTrue();
}

[WinFormsFact]
public void PaintOver_AppearanceNormal_CallsPaintUp()
{
using RadioButton control = new RadioButton
{
Appearance = Appearance.Normal,
Checked = false
};

RadioButtonStandardAdapter adapter = new(control);
using Bitmap bitmap = new Bitmap(1, 1);
using Graphics graphics = Graphics.FromImage(bitmap);
PaintEventArgs e = new(graphics, control.ClientRectangle);

adapter.PaintOver(e, CheckState.Unchecked);

control.Appearance.Should().Be(Appearance.Normal);
control.Checked.Should().BeFalse();
}
}