Beispiel #1
0
        public void TestUpsertListExtensionDoesUpdate()
        {
            var list = new List<MockDataModel>();
            var item1 = new MockDataModel()
                {
                    MyBoolProperty = true,
                    MyStringProperty = "this is item 1"
                };

            var item2 = new MockDataModel()
                {
                    MyBoolProperty = false,
                    MyStringProperty = "this is item 2"
                };

            list.Upsert(item1);
            list.Upsert(item2);

            item1.MyStringProperty = "modifying the item 1";

            list.Upsert(item1);

            Assert.AreEqual(list.Count, 2);
            Assert.AreEqual(list[0], item1);
            Assert.AreEqual(list[1], item2);
        }
        public async Task TestDataModelGetsPassedIntoViewModelOnNavigation()
        {
            var myModel = new MockDataModel();

            // have to run this test on the UI thread since it involves Frames/Navigation
            await ExecuteOnUIThreadAsync(async () =>
            {
                // navigate to page 1
                await CoreServiceLocator.Default.GetInstance<INavigationService>().NavigateToTestPage1Async(myModel);

                // timeout after 2000 ms
                var timeoutIterator = 20;
                var dc = (Window.Current.Content as Frame).DataContext as MockPageViewModel;
                while (dc == null)
                {
                    // have to slight delay to allow OnNavigatedTo to set data context
                    await Task.Delay(100);
                    if(timeoutIterator-- <=0)
                    {
                        throw new TimeoutException("datacontext never set for bindable page");
                    }
                    dc = (Window.Current.Content as Frame).DataContext as MockPageViewModel;
                }
                Assert.AreEqual(dc.MyMockDataModel, myModel);
            });
        }
Beispiel #3
0
        public void TestUpsertListExtensionDoesInsert()
        {
            var list = new List<MockDataModel>();
            var item1 = new MockDataModel()
            {
                MyBoolProperty = true,
                MyStringProperty = "this is item 1"
            };

            list.Upsert(item1);

            Assert.AreEqual(list.Count, 1);
            Assert.AreEqual(list[0], item1);
        }
        public Task NavigateToModalBusyTestPageAsync(MockDataModel mockModel)
        {
            base.NavigateToPage(typeof(ModalBusyTestPage), mockModel);

            return TaskHelper.CompletedTask;
        }
 public MockPageViewModel(MockDataModel data)
 {
     MyMockDataModel = data;
 }