public void Setup()
        {
            // Initilize Xamarin Forms
            MockForms.Init();

            // Activate the Datastore
            DependencyService.Register <MockDataStore>();

            ViewModel = new ItemIndexViewModel();

            // Load Data
            ViewModel.ForceDataRefresh();
        }
        public async Task ItemIndexViewModel_Add_Valid_Should_Pass()
        {
            // Arrange
            var data = new ItemModel
            {
                Name = "New Item"
            };

            // Act
            var result = await ViewModel.Add(data);

            // Reset

            // Need to clear the added item, and reload the dataset
            ViewModel.Dataset.Clear();
            ViewModel.ForceDataRefresh();

            // Assert
            Assert.AreEqual(true, result);  // Update returned Pass
        }
Esempio n. 3
0
        public void ItemIndexViewModel_ExecuteLoadDataCommand_Valid_IsBusy_Should_Pass()
        {
            // Arrange

            // Setting IsBusy will have the Load skip
            ViewModel.IsBusy = true;

            // Clear the Dataset, so no records
            ViewModel.Dataset.Clear();

            // Act
            ViewModel.LoadDatasetCommand.Execute(null);
            var count = ViewModel.Dataset.Count();  // Remember how many records exist

            // Reset
            ViewModel.IsBusy = false;
            ViewModel.ForceDataRefresh();

            // Assert
            Assert.AreEqual(0, count); // Count of 0 for the load was skipped
        }