public void AddNormalProductEventsAddCheck() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100, }; SellService sellService = new SellService(this._repository); bool isAddCalled = false; bool isAddedCalled = false; sellService.OnAddProduct += (sender, args) => { isAddCalled = true; }; sellService.OnAddedProduct += (sender, args) => { isAddedCalled = true; }; sellService.AddProduct(product); Assert.IsTrue(isAddCalled); Assert.IsTrue(isAddedCalled); Assert.AreEqual(product, this._repository.Get(0)); }
public IProduct Unmap(ProductData data) { var product = new ConcreteProduct(); // map properties return(product); }
static void Main(string[] args) { User FirstUser = new User { Name = "First User", UserId = 1 }; User SecondUser = new User { Name = "Second User", UserId = 2 }; ConcreteProduct Book = new ConcreteProduct { Name = "Book1", Price = 500, Discount = 0, Id = 1, AmountInStock = 5, }; Book.AttachObserver(FirstUser); Book.AttachObserver(SecondUser); Book.AmountInStock = 10; Book.DetachObserver(SecondUser); Book.Price = 550; Console.ReadLine(); }
static void Main(string[] args) { #region Lab_1 var customerObserver = new CustomerObserver(); ProductManager productManager = new ProductManager(); productManager.Attached(customerObserver); productManager.Attached(new EmployeeObserver()); productManager.UpdatePrice(); Console.ReadKey(); #endregion #region ConcreteProduct product = new ConcreteProduct("Boxing Gloves", 12.25M); product.FollowList.Add(new ConcreteMember { Email = "*****@*****.**" }); product.Price = 8.99M; Console.ReadKey(); #endregion . }
static void Main(string[] args) { #region Lab_1 var customerObesrver = new CustomerObserver(); var employeeObserver = new EmployeeObserver(); ProductSubject productSubject = new ProductSubject(); productSubject.Attached(customerObesrver); productSubject.Attached(employeeObserver); productSubject.Update(); #endregion Console.WriteLine("\n"); #region Lab_2 ConcreteProduct concreteProduct = new ConcreteProduct("HP Laptop", 12); concreteProduct.members.Add(new ConcreteMember { EmailAddress = "*****@*****.**" }); concreteProduct.members.Add(new ConcreteMember { EmailAddress = "*****@*****.**" }); concreteProduct.Price = 15; #endregion Console.ReadKey(); }
public void SellNormalProductEventCheck() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; SellService sellService = new SellService(this._repository); bool isSellChecked = false; bool isSoldChecked = false; sellService.OnSellProduct += (sender, args) => { isSellChecked = true; }; sellService.OnSoldProduct += (sender, args) => { isSoldChecked = true; }; sellService.AddProduct(product); sellService.SellProduct(product); Assert.IsTrue(isSellChecked); Assert.IsTrue(isSoldChecked); Assert.AreEqual((uint)49, this._repository.Get(0).Count); }
public void AddTwoNormalProducts() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; ConcreteProduct product2 = new ConcreteProduct() { Name = "My Super Product 2", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; SellService sellService = new SellService(this._repository); sellService.AddProduct(product); sellService.AddProduct(product2); Assert.AreEqual(product, this._repository.Get(0)); Assert.AreEqual(product2, this._repository.Get(1)); }
public void AddInvalidProductNull() { ConcreteProduct product = null; SellService sellService = new SellService(this._repository); sellService.AddProduct(product); }
static void Main(string[] args) { Creator creator = new ConcreteCreator(); Product product = creator.Factory_Method(); ConcreteProduct concreteProduct = product as ConcreteProduct; concreteProduct.DoWork(); }
public void InvalidProductBadNameEmpty() { ConcreteProduct product = new ConcreteProduct() { Name = string.Empty, Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; }
public void InvalidProductWidth() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = -100 }; }
public static void Main() { Creator cr = new Creator(); cr.Send(); ConcreteCreator ccr = new ConcreteCreator(); ccr.Send(); Product pr = new Product(); pr.CreateProduct(); ConcreteProduct cpr = new ConcreteProduct(); cpr.CreateProduct(); }
public void DeleteUnExcitedProduct() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; SellService sellService = new SellService(this._repository); sellService.AddProduct(product); sellService.DeleteProduct(510); }
public void UpdateNullProduct() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; ConcreteProduct product2 = null; SellService sellService = new SellService(this._repository); sellService.AddProduct(product); sellService.UpdateProduct(product2); }
public void DeleteNormalProduct() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; SellService sellService = new SellService(this._repository); sellService.AddProduct(product); sellService.DeleteProduct(0); Assert.IsNull(this._repository.Get(0)); }
public void SellNormalProduct() { ConcreteProduct product = new ConcreteProduct() { Name = "My Super Product", Description = "Description of my super product", Weight = 100, Price = 100, Count = 50, Height = 100, Width = 100 }; SellService sellService = new SellService(this._repository); sellService.AddProduct(product); sellService.SellProduct(product); Assert.AreEqual((uint)49, this._repository.Get(0).Count); }
public void Execute() { ConcreteProduct product = new ConcreteProduct(); Shop shop1 = new Shop("Shop1"); Shop shop2 = new Shop("Shop2"); Shop shop3 = new Shop("Shop3"); Shop shop4 = new Shop("Shop4"); product.Attach(shop1); product.Attach(shop2); product.Attach2(shop3); product.Attach2(shop4); product.ChangePrice(4.7f); product.Remove2(shop3); product.Remove(shop2); product.ChangePrice(25.6f); }