summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.UnitTests/SwitchUnitTests.cs
blob: 9748c3e9cb22c3c64ac81075f980eeb115cee059 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;

using NUnit.Framework;

namespace Xamarin.Forms.Core.UnitTests
{
	[TestFixture]
	public class SwitchUnitTests : BaseTestFixture
	{
		[Test]
		public void TestConstructor ()
		{
			Switch sw = new Switch ();

			Assert.IsFalse (sw.IsToggled);
		}

		[Test]
		public void TestOnEvent ()
		{
			Switch sw = new Switch ();

			bool fired = false;
			sw.Toggled += (sender, e) => fired = true;

			sw.IsToggled = true;

			Assert.IsTrue (fired);
		}

		[Test]
		public void TestOnEventNotDoubleFired ()
		{
			var sw = new Switch ();

			bool fired = false;
			sw.IsToggled = true;

			sw.Toggled += (sender, args) => fired = true;
			sw.IsToggled = true;

			Assert.IsFalse (fired);
		}
	}
	
}