diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Core.UnitTests/EntryUnitTests.cs | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Core.UnitTests/EntryUnitTests.cs')
-rw-r--r-- | Xamarin.Forms.Core.UnitTests/EntryUnitTests.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/EntryUnitTests.cs b/Xamarin.Forms.Core.UnitTests/EntryUnitTests.cs new file mode 100644 index 00000000..83f71b9a --- /dev/null +++ b/Xamarin.Forms.Core.UnitTests/EntryUnitTests.cs @@ -0,0 +1,55 @@ +using System.Diagnostics; + +using NUnit.Framework; + +namespace Xamarin.Forms.Core.UnitTests +{ + [TestFixture] + public class EntryUnitTests : BaseTestFixture + { + [Test] + public void ValueChangedFromSetValue() + { + var entry = new Entry(); + + const string value = "Foo"; + + bool signaled = false; + entry.TextChanged += (sender, args) => { + signaled = true; + Assert.AreEqual (value, args.NewTextValue); + }; + + entry.SetValue (Entry.TextProperty, value); + + Assert.IsTrue (signaled, "ValueChanged did not fire"); + } + + [TestCase (null, "foo")] + [TestCase ("foo", "bar")] + [TestCase ("foo", null)] + public void ValueChangedArgs (string initial, string final) + { + var entry = new Entry { + Text = initial + }; + + string oldValue = null; + string newValue = null; + + Entry entryFromSender = null; + + entry.TextChanged += (s, e) => { + entryFromSender = (Entry)s; + oldValue = e.OldTextValue; + newValue = e.NewTextValue; + }; + + entry.Text = final; + + Assert.AreEqual (entry, entryFromSender); + Assert.AreEqual (initial, oldValue); + Assert.AreEqual (final, newValue); + } + } +} |