summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UnitTests/EditorTests.cs
blob: c16f1d2adef8757f3d47d1b398fb50554a97b48d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using NUnit.Framework;

namespace Xamarin.Forms.Core.UnitTests
{
	[TestFixture]
	public class EditorTests : BaseTestFixture
	{
		[TestCase ("Hi", "My text has changed")]
		[TestCase (null, "My text has changed")]
		[TestCase ("Hi", null)]
		public void EditorTextChangedEventArgs (string initialText, string finalText)
		{
			var editor = new Editor {
				Text = initialText
			};

			Editor editorFromSender = null;
			string oldText = null;
			string newText = null;

			editor.TextChanged += (s, e) => {
				editorFromSender = (Editor)s;
				oldText = e.OldTextValue;
				newText = e.NewTextValue;
			};

			editor.Text = finalText;

			Assert.AreEqual (editor, editorFromSender);
			Assert.AreEqual (initialText, oldText);
			Assert.AreEqual (finalText, newText);
		}
	}
}