public void GetProductRepositoryTestIsCalled() { //Arrange MainWindow windowTest = new MainWindow(); var MockNotificationSvc = new Mock<INotificationService>(); var MockPaymentProcessor = new Mock<IPaymentProcessor>(); var MockProductRepo = new Mock<IProductRepository>(); OrderItemRepository orderRepo = new OrderItemRepository(); Cart ActiveCart = new Cart(orderRepo); List<Product> catalogProducts = new List<Product>() { new Product(){Name = "cable", OnHand = 5}, new Product(){Name = "charger", OnHand = 4}, new Product() {Name = "battery", OnHand = 3} }; MockProductRepo.Setup(x => x.GetProducts()).Returns(catalogProducts); //Act windowTest.ListProductsInCatalog(MockProductRepo.Object); Assert.AreEqual(true, windowTest.lstSelection.Items.Contains("cable")); MockProductRepo.Verify(x => x.GetProducts()); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.frmShoppingCart = ((ShoppingCart.MainWindow)(target)); #line 8 "..\..\MainWindow.xaml" this.frmShoppingCart.Loaded += new System.Windows.RoutedEventHandler(this.OnWindowLoaded); #line default #line hidden return; case 2: this.label = ((System.Windows.Controls.Label)(target)); return; case 3: this.labelProducts = ((System.Windows.Controls.Label)(target)); return; case 4: this.listBoxProducts = ((System.Windows.Controls.ListBox)(target)); return; case 5: this.labelCart = ((System.Windows.Controls.Label)(target)); return; case 6: this.listBoxCart = ((System.Windows.Controls.ListBox)(target)); return; case 7: this.btnAddTax = ((System.Windows.Controls.Button)(target)); #line 16 "..\..\MainWindow.xaml" this.btnAddTax.Click += new System.Windows.RoutedEventHandler(this.btnAddTax_Click); #line default #line hidden return; case 8: this.btnExit = ((System.Windows.Controls.Button)(target)); #line 17 "..\..\MainWindow.xaml" this.btnExit.Click += new System.Windows.RoutedEventHandler(this.btnExit_Click); #line default #line hidden return; case 9: this.btnAddToCart = ((System.Windows.Controls.Button)(target)); #line 18 "..\..\MainWindow.xaml" this.btnAddToCart.Click += new System.Windows.RoutedEventHandler(this.btnAddToCart_Click); #line default #line hidden return; case 10: this.btnRemoveFromCart = ((System.Windows.Controls.Button)(target)); #line 19 "..\..\MainWindow.xaml" this.btnRemoveFromCart.Click += new System.Windows.RoutedEventHandler(this.btnRemoveFromCart_Click); #line default #line hidden return; case 11: this.labelTotal = ((System.Windows.Controls.Label)(target)); return; case 12: this.totalAmount = ((System.Windows.Controls.Label)(target)); return; case 13: this.comboBoxBikeType = ((System.Windows.Controls.ComboBox)(target)); #line 22 "..\..\MainWindow.xaml" this.comboBoxBikeType.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.comboBoxBikeType_SelectionChanged); #line default #line hidden return; case 14: this.labelBikeType = ((System.Windows.Controls.Label)(target)); return; } this._contentLoaded = true; }
public void WhenTwoisSelectedAndAddisClickedTwoProductsAreAdded() { //Arrange MainWindow windowTest = new MainWindow(); List<Product> catalogProducts = new List<Product>() { new Product(){Name = "cable", OnHand = 5}, new Product(){Name = "charger", OnHand = 4}, new Product() {Name = "battery", OnHand = 3} }; //Act windowTest.cbQuantity.SelectedItem = "2"; windowTest.lstSelection.SelectedItem = "battery"; windowTest.AddItemToCart(); //Assert Assert.AreEqual(2, windowTest.orderRepo.CartItems[3].Quantity); }