예제 #1
0
        public void MainViewModelSearchInventoriesTest()
        {
            MockInventoryService newMockInventoryService = InitializeMockInventoryService();

            using (MainViewModel mainViewModel = new MainViewModel(new InventoryModel(newMockInventoryService)))
            {
                mainViewModel.FindProductsCommand.Execute(null);
                Assert.AreEqual(1, mainViewModel.StoresWithInventories.Count);
                Assert.AreEqual(-79.0, mainViewModel.StoresWithInventories[0].Location.Latitude);
                Assert.AreEqual(41.0, mainViewModel.StoresWithInventories[0].Location.Longitude);
                Assert.AreEqual("Store 1 Toronto", mainViewModel.StoresWithInventories[0].Address);
                Assert.AreEqual(1, mainViewModel.StoresWithInventories[0].InventoryInfo.Count);
                Assert.AreEqual(5, mainViewModel.StoresWithInventories[0].InventoryInfo[0].NumberInStock);
                Assert.AreEqual(1, mainViewModel.StoresWithInventories[0].InventoryInfo[0].Product.Id);
                Assert.AreEqual("Product 1", mainViewModel.StoresWithInventories[0].InventoryInfo[0].Product.Name);
            }
        }
예제 #2
0
        public void MainViewModelInitTest()
        {
            MockInventoryService newMockInventoryService = InitializeMockInventoryService();

            using (MainViewModel mainViewModel = new MainViewModel(new InventoryModel(newMockInventoryService)))
            {
                Assert.AreEqual(2, mainViewModel.Products.Count);
                Assert.AreEqual(-1, mainViewModel.Products[0].Id);
                Assert.AreEqual("Your products", mainViewModel.Products[0].Name);
                Assert.AreEqual(1, mainViewModel.Products[1].Id);
                Assert.AreEqual("Product 1", mainViewModel.Products[1].Name);
                Assert.AreEqual(-1, mainViewModel.CurrentProduct.Id);

                Assert.AreEqual(3, mainViewModel.Stores.Count);
                Assert.AreEqual(-1, mainViewModel.Stores[0].Id);
                Assert.AreEqual("Your stores", mainViewModel.Stores[0].Address);
                Assert.AreEqual(-2, mainViewModel.Stores[1].Id);
                Assert.AreEqual("All stores", mainViewModel.Stores[1].Address);
                Assert.AreEqual(1, mainViewModel.Stores[2].Id);
                Assert.AreEqual("Store 1, Toronto", mainViewModel.Stores[2].Address);
                Assert.AreEqual(-1, mainViewModel.CurrentStore.Id);
            }
        }
예제 #3
0
 /// <summary>
 /// Provides a deterministic way to create the Main property.
 /// </summary>
 public static void CreateMain()
 {
     if (ViewModelLocator.main == null)
     {
         ViewModelLocator.main = new MainViewModel();
     }
 }
예제 #4
0
 /// <summary>
 /// Provides a deterministic way to delete the Main property.
 /// </summary>
 public static void ClearMain()
 {
     ViewModelLocator.main.Cleanup();
     ViewModelLocator.main = null;
 }