From 5907152c50ee2c658b266f2804e6b383bb15a6f1 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 24 Apr 2016 12:25:26 -0400 Subject: Evolve feature branch (#117) * Initial import of evolve features * [Android] Add Xamarin.Forms.Platform.Android.AppLinks project * [iOS] Fix issues with c# 6 features on iOS AppLinks * Added naive stanza to update-docs-windows.bat to produce Pages docs. Not tested. (#69) * Update packages * Add AppLinks android nuspec and fix linker issues * Fix build * Fix nusepc * Fix nuspec * Update android support nugets to 23.2.1 * Update Xamarin.UITest * Add CardView * [iOS] Fix app link for CoreSpotlight * [Android] Update AppLinks android support libs * Add Newtonsoft.Json dependency to nuspec * Fix NRE when setting ControlTemplate to null * Move to ModernHttpClient for download * Try fix build * Preserve android app links * Fix margin issue * General coding and simple fixes --- Xamarin.Forms.Pages.UnitTests/IntegrationTests.cs | 150 ++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 Xamarin.Forms.Pages.UnitTests/IntegrationTests.cs (limited to 'Xamarin.Forms.Pages.UnitTests/IntegrationTests.cs') diff --git a/Xamarin.Forms.Pages.UnitTests/IntegrationTests.cs b/Xamarin.Forms.Pages.UnitTests/IntegrationTests.cs new file mode 100644 index 00000000..480706fc --- /dev/null +++ b/Xamarin.Forms.Pages.UnitTests/IntegrationTests.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Pages.UnitTests +{ + [TestFixture] + internal class IntegrationTests + { + [SetUp] + public void Setup () + { + Device.PlatformServices = new MockPlatformServices (); + } + + [TearDown] + public void TearDown () + { + Device.PlatformServices = null; + } + + public class SimpleDataSource : BaseDataSource + { + readonly ObservableCollection dataItems = new ObservableCollection (); + string json; + + public SimpleDataSource () + { + Json = @"{ + 'Name' : 'Jason Smith', + 'Phone' : '(555)248-7561', + 'PrimaryEmail' : 'jason@xamarin.com', + 'JobTitle' : 'Software Engineering Manager', + 'TimeZone' : 'PST', + 'Image' : 'https://c1.staticflickr.com/3/2877/10612763564_7f2d1734ea_b.jpg', + 'Address' : '430 Pacific Ave, San Francisico CA, 55592', +}"; + } + + public string Json + { + get { return json; } + set + { + json = value; + try { + var dict = JsonConvert.DeserializeObject> (json); + foreach (var kvp in dict) + dataItems.Add (new DataItem (kvp.Key, kvp.Value)); + } catch (Exception ex) { + Debug.WriteLine (ex.Message); + } + } + } + + protected override Task> GetRawData () + { + return Task.FromResult> (dataItems); + } + + protected override object GetValue (string key) + { + var target = dataItems.FirstOrDefault (d => d.Name == key); + if (target == null) + return null; + //throw new KeyNotFoundException (); + return target.Value; + } + + protected override bool SetValue (string key, object value) + { + var target = dataItems.FirstOrDefault (d => d.Name == key); + if (target == null) { + dataItems.Add (new DataItem (key, value)); + return true; + } + if (target.Value == value) + return false; + target.Value = value; + return true; + } + } + + public class TestPage : PersonDetailPage + { + public TestPage () + { + SetBinding (DisplayNameProperty, new DataSourceBinding ("Name")); + SetBinding (PhoneNumberProperty, new DataSourceBinding ("Phone")); + SetBinding (EmailProperty, new DataSourceBinding ("PrimaryEmail")); + } + } + + [Test] + public void Test1 () + { + var page = new TestPage (); + + page.DataSource = new SimpleDataSource (); + page.Platform = new UnitPlatform(); + + Assert.AreEqual (9, page.DataSource.MaskedKeys.Count ()); + } + + [Test] + public void JsonDataSourceComplex () + { + var jsonDataSource = new JsonDataSource (); + + var json = @"[ + { + 'Name': 'Kristen Perez', + 'Address': 'Ap #325-3386 Ac Av.', + 'Phone': '(016977) 7108', + 'Title': 'Lorem Ipsum Dolor Incorporated', + 'Email': 'ac.risus.Morbi@interdum.co.uk', + 'List' : [ + 'Foo', 'Bar', 'Baz' + ] + }, + { + 'Name': 'Murphy Cote', + 'Address': '906-6938 Porttitor Ave', + 'Phone': '076 9223 8954', + 'Title': 'Vulputate Industries', + 'Email': 'non@consequat.ca', + 'List' : [ { 'Second' : 'Thing' } ] + }, + { + 'Name': 'Nicole Valdez', + 'Address': '485-9530 Ut Rd.', + 'Phone': '0800 364 0760', + 'Title': 'Diam At Ltd', + 'Email': 'nisl@ipsum.edu' + } +]"; + jsonDataSource.Source = json; + Debug.WriteLine (jsonDataSource); + } + } +} -- cgit v1.2.3