Add a combobox test

This commit is contained in:
niksedk 2023-08-06 11:35:48 +02:00
parent 5406fc1d0d
commit 7345b1c466
3 changed files with 57 additions and 4 deletions

View File

@ -119,7 +119,8 @@
<Compile Include="Logic\SubtitleFormats\SubtitleFormatsTest.cs" />
<Compile Include="Logic\UtilitiesTest.cs" />
<Compile Include="Dictionaries\XmlDictionariesTest.cs" />
<Compile Include="SETextBoxControl\SeTextBoxTests.cs" />
<Compile Include="UserControls\NikseComboBoxTests.cs" />
<Compile Include="UserControls\SeTextBoxTests.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Dictionaries\en_US.aff" />

View File

@ -0,0 +1,52 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Nikse.SubtitleEdit.Controls;
using System.Windows.Forms;
namespace Test.UserControls
{
[TestClass]
public class NikseComboBoxTests
{
[TestMethod]
public void NikseComboBox()
{
var cbNormal = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList};
var normalSelectedIndexChangedCount = 0;
cbNormal.SelectedIndexChanged += (sender, args) => { normalSelectedIndexChangedCount++; };
var normalSelectedValueChangedCount = 0;
cbNormal.SelectedValueChanged += (sender, args) => { normalSelectedValueChangedCount++; };
var cbNikse = new NikseComboBox { DropDownStyle = ComboBoxStyle.DropDownList };
var nikseSelectedIndexChangedCount = 0;
cbNikse.SelectedIndexChanged += (sender, args) => { nikseSelectedIndexChangedCount++; };
var nikseSelectedValueChangedCount = 0;
cbNikse.SelectedValueChanged += (sender, args) => { nikseSelectedValueChangedCount++; };
cbNormal.Items.Add("Test");
cbNikse.Items.Add("Test");
Verify(normalSelectedIndexChangedCount, nikseSelectedIndexChangedCount, normalSelectedValueChangedCount, nikseSelectedValueChangedCount, cbNormal, cbNikse);
cbNormal.SelectedIndex = 0;
cbNikse.SelectedIndex = 0;
Verify(normalSelectedIndexChangedCount, nikseSelectedIndexChangedCount, normalSelectedValueChangedCount, nikseSelectedValueChangedCount, cbNormal, cbNikse);
cbNormal.Items.Clear();
cbNikse.Items.Clear();
Verify(normalSelectedIndexChangedCount, nikseSelectedIndexChangedCount, normalSelectedValueChangedCount, nikseSelectedValueChangedCount, cbNormal, cbNikse);
}
private static void Verify(int normalSelectedIndexChangedCount, int nikseSelectedIndexChangedCount, int normalSelectedValueChangedCount, int nikseSelectedValueChangedCount, ComboBox cbNormal, NikseComboBox cbNikse)
{
Assert.AreEqual(normalSelectedIndexChangedCount, nikseSelectedIndexChangedCount);
Assert.AreEqual(normalSelectedValueChangedCount, nikseSelectedValueChangedCount);
Assert.AreEqual(cbNormal.SelectedIndex, cbNikse.SelectedIndex);
//Assert.AreEqual(cbNormal.Text, cbNikse.Text);
Assert.AreEqual(cbNormal.SelectedItem, cbNikse.SelectedItem);
//Assert.AreEqual(cbNormal.SelectedText, cbNikse.SelectedText);
}
}
}

View File

@ -1,9 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core.Common;
using System;
namespace Test.SETextBoxControl
namespace Test.UserControls
{
[TestClass]
public class SeTextBoxTests