diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewCellStyleConverterTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewCellStyleConverterTests.cs new file mode 100644 index 00000000000..199298ab72d --- /dev/null +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewCellStyleConverterTests.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable enable + +using System.ComponentModel.Design.Serialization; +using System.Globalization; + +namespace System.Windows.Forms.Tests; + +public class DataGridViewCellStyleConverterTests +{ + private readonly DataGridViewCellStyleConverter _converter; + private readonly DataGridViewCellStyle _style; + + public DataGridViewCellStyleConverterTests() + { + _converter = new(); + _style = new(); + } + + [WinFormsFact] + public void CanConvertTo_InstanceDescriptor_ReturnsTrue() + { + _converter.CanConvertTo(null, typeof(InstanceDescriptor)).Should().BeTrue(); + } + + [WinFormsFact] + public void CanConvertTo_OtherType_ReturnsFalse() + { + _converter.CanConvertTo(null, typeof(int)).Should().BeFalse(); + } + + [WinFormsFact] + public void ConvertTo_InstanceDescriptor_ReturnsInstanceDescriptor() + { + object? convertTo = _converter.ConvertTo(null, CultureInfo.InvariantCulture, _style, typeof(InstanceDescriptor)); + convertTo.Should().NotBeNull(); + convertTo.Should().BeOfType(); + } + + [WinFormsFact] + public void ConvertTo_UnsupportedType_ThrowsNotSupportedException() + { + Action action = () => _converter.ConvertTo(null, CultureInfo.InvariantCulture, _style, typeof(int)); + action.Should().Throw(); + } +}