public void InitViewModelTest()
        {
            MockStoreService storeService = BuildStoreService();

            using (ManageStoresViewModel viewModel = new ManageStoresViewModel(new StoreModel(storeService)))
            {
                Assert.AreEqual(4, viewModel.AllCities.Count);
                Assert.AreEqual("Springfield", viewModel.AllCities[0].Name);

                Assert.AreEqual(1, viewModel.PersonalLocations.Count);
                Assert.AreEqual("Home", viewModel.PersonalLocations[0].Description);
                Assert.AreEqual(42.0M, viewModel.PersonalLocations[0].Latitude);
                Assert.AreEqual(-78.0M, viewModel.PersonalLocations[0].Longitude);
                Assert.AreEqual(1, viewModel.PersonalLocations[0].Id);

                Assert.AreEqual(1, viewModel.UserStores.Count);
                Assert.AreEqual("123 Fake St., Springfield", viewModel.UserStores[0].Address);
                Assert.AreEqual(1, viewModel.UserStores[0].Id);
                Assert.AreEqual(43.0M, viewModel.UserStores[0].Latitude);
                Assert.AreEqual(-79.0M, viewModel.UserStores[0].Longitude);

                Assert.AreEqual(5, viewModel.SearchRadiusItems.Count);
                Assert.AreEqual(5, viewModel.SearchRadiusItems[0]);
                Assert.AreEqual(10, viewModel.SearchRadiusItems[1]);
                Assert.AreEqual(15, viewModel.SearchRadiusItems[2]);
                Assert.AreEqual(20, viewModel.SearchRadiusItems[3]);
                Assert.AreEqual(2000, viewModel.SearchRadiusItems[4]);
                Assert.AreEqual(5, viewModel.SearchRadius);
            }
        }
        public void AddStoreTest()
        {
            MockStoreService storeService = BuildStoreService();
            using (ManageStoresViewModel viewModel = new ManageStoresViewModel(new StoreModel(storeService)))
            {
                viewModel.SearchResults = new ObservableCollection<Models.ViewModels.Elements.UserStoreViewModel>
                {
                    new UserStoreViewModel(
                        new StoreViewModel()
                        {
                            Id = 10
                        }
                    )
                    {
                        UsedByUser = false
                    }
                };

                Assert.AreEqual(1, viewModel.UserStores.Count);
                viewModel.AddStoreCommand.Execute(viewModel.SearchResults[0]);
                Assert.IsTrue(storeService.AddCalled);
                Assert.AreEqual(2, viewModel.UserStores.Count);
                Assert.IsTrue(viewModel.SearchResults[0].UsedByUser);
                Assert.AreEqual(10, viewModel.UserStores[1].Id);
            }
        }
 public void DeleteStoreTest()
 {
     MockStoreService storeService = BuildStoreService();
     using (ManageStoresViewModel viewModel = new ManageStoresViewModel(new StoreModel(storeService)))
     {
         Assert.AreEqual(1, viewModel.UserStores.Count);
         viewModel.RemoveStoreCommand.Execute(viewModel.UserStores[0]);
         Assert.IsTrue(storeService.DeleteCalled);
         Assert.AreEqual(0, viewModel.UserStores.Count);
     }
 }
        public void SearchByPostalCodeTest()
        {
            MockStoreService storeService = BuildStoreService();
            using (ManageStoresViewModel viewModel = new ManageStoresViewModel(new StoreModel(storeService)))
            {
                viewModel.PostalCode = "L6H 6J1";
                viewModel.FindStoresByPostalCodeCommand.Execute(null);
                Assert.AreEqual(1, viewModel.SearchResults.Count);

                Assert.AreEqual(2, viewModel.SearchResults[0].Store.Id);
                Assert.AreEqual("742 Evergreen Tr., Springfield", viewModel.SearchResults[0].Store.Address);
                Assert.AreEqual(42.0M, viewModel.SearchResults[0].Store.Latitude);
                Assert.AreEqual(-80.0M, viewModel.SearchResults[0].Store.Longitude);
                Assert.IsFalse(viewModel.SearchResults[0].UsedByUser);
                Assert.AreEqual(viewModel.SearchRadius, storeService.RadiusSearched);
            }
        }
        public void SearchByPersonalLocationTest()
        {
            MockStoreService storeService = BuildStoreService();
            using (ManageStoresViewModel viewModel = new ManageStoresViewModel(new StoreModel(storeService)))
            {

                viewModel.FindStoresByPersonalLocationCommand.Execute(viewModel.PersonalLocations[0]);
                Assert.AreEqual(1, viewModel.SearchResults.Count);

                Assert.AreEqual(4, viewModel.SearchResults[0].Store.Id);
                Assert.AreEqual("Mr Burns' House, Springfield", viewModel.SearchResults[0].Store.Address);
                Assert.AreEqual(40.0M, viewModel.SearchResults[0].Store.Latitude);
                Assert.AreEqual(-82.0M, viewModel.SearchResults[0].Store.Longitude);
                Assert.IsFalse(viewModel.SearchResults[0].UsedByUser);
                Assert.AreEqual(viewModel.SearchRadius, storeService.RadiusSearched);
            }
        }
        public void SearchByCityTest()
        {
            MockStoreService storeService = BuildStoreService();
            using (ManageStoresViewModel viewModel = new ManageStoresViewModel(new StoreModel(storeService)))
            {
                viewModel.FindStoresCommand.Execute(viewModel.AllCities[0].Name);
                Assert.AreEqual(1, viewModel.SearchResults.Count);

                Assert.AreEqual(1, viewModel.SearchResults[0].Store.Id);
                Assert.AreEqual("123 Fake St., Springfield", viewModel.SearchResults[0].Store.Address);
                Assert.AreEqual(43.0M, viewModel.SearchResults[0].Store.Latitude);
                Assert.AreEqual(-79.0M, viewModel.SearchResults[0].Store.Longitude);
                Assert.IsTrue(viewModel.SearchResults[0].UsedByUser);
            }
        }
 /// <summary>
 /// Provides a deterministic way to create the ManageStoresViewModel property.
 /// </summary>
 public static void CreateManageStoresViewModel()
 {
     if (manageStores == null)
     {
         manageStores = new ManageStoresViewModel();
     }
 }
        /// <summary>
        /// Provides a deterministic way to delete the ManageStoresViewModel property.
        /// </summary>
        public static void ClearManageStoresViewModel()
        {
            if (manageStores != null)
            {
                manageStores.Cleanup();
            }

            manageStores = null;
        }