private void InitialEnvironment() { _phoneCaseService = new Services.Implementation.PhoneCaseService(_phoneCaseRepository.Object); //Set environment DontRefactor.Models.PhoneCase[] list = new PhoneCase[] { new PhoneCase() { Id = Guid.NewGuid(), Name = "Amazon Fire Burgundy Phone Case", Colour = "Burgundy", Material = "PVC", TargetPhone = "Amazon Fire", Price = 14.0 }, new PhoneCase() { Id = Guid.NewGuid(), Name = "Nokia Lumia 920/930/Icon Crimson Phone Case", Colour = "Red", Material = "Rubber", TargetPhone = "Nokia Lumia 920/930/Icon", Price = 10.0 } }; _phoneCaseRepository.Setup(l => l.GetAll()).Returns(list.AsQueryable()); }
private void AssertEqual(ProductEx p1, PhoneCase p2, double rate = 1) { Assert.AreEqual(p1.Id, p2.Id); Assert.AreEqual(p1.Name, p2.Name); Assert.AreEqual(p1.Price, p2.Price * rate); Assert.AreEqual(p1.Type, "Phone Case"); }
public static void DecoratorExample() { blankLine(); Split("Decorator"); var newCase = new PhoneCase(new Sony()); newCase.IsPhoneCasePresented(); }
public void InsertPhoneCase(PhoneCase newPhoneCase) { SqlParameter p1 = new SqlParameter("ProductName", newPhoneCase.ProductName); SqlParameter p2 = new SqlParameter("Price", newPhoneCase.Price); SqlParameter p3 = new SqlParameter("CaseColor", (int)newPhoneCase.CaseColor); SqlParameter p4 = new SqlParameter("Quantity", newPhoneCase.Quantity); Program.SqlHelper.ExecutePro("InsertPhoneCases", p1, p2, p3, p4); }
public static Product ToProduct(this PhoneCase phoneCase) { return(new Product { Id = phoneCase.Id, Name = phoneCase.Name, Price = phoneCase.Price, //FIXME: Prices REALLY should have been Decimal not Double... Type = "Phone Case" //FIXME: Type really should be an enum... }); }
public List <PhoneCase> GetPhoneCases() { List <PhoneCase> list = new List <PhoneCase>(); DataTable dt = Program.SqlHelper.GetTable("Select * From PhoneCase"); foreach (DataRow row in dt.Rows) { PhoneCase p = new PhoneCase(); p.ID = (int)row["ID"]; p.ProductName = row["ProductName"].ToString(); p.Price = (decimal)row["Price"]; p.CaseColor = (CaseColor)row["CaseColor"]; p.Quantity = (int)row["Quantity"]; list.Add(p); } return(list); }
public List <PhoneCase> GetPhoneCases() { List <PhoneCase> list = new List <PhoneCase>(); DataTable dt = Program.SqlHelper.GetTable("SELECT * FROM PhoneCases"); foreach (DataRow item in dt.Rows) { PhoneCase p = new PhoneCase(); p.ID = (int)item["ID"]; p.ProductName = item["ProductName"].ToString(); p.Price = (decimal)item["Price"]; p.StockQTY = (int)item["StockQTY"]; p.CaseColor = (CaseColor)item["CaseColor"]; list.Add(p); } return(list); }
public void InsertPhoneCase(PhoneCase newPhoneCase) { #region Ver1 /* Program.SqlHelper.ExecuteCommand(@"INSERT INTO [dbo].[PhoneCases] * ([ProductName] * ,[Price] * ,[CaseColor] * ,[StockQTY]) VALUES ('"+newPhoneCase.ProductName+"',"+newPhoneCase.Price+","+(int)newPhoneCase.CaseColor+","+newPhoneCase.StockQTY+")"); */ #endregion #region Ver2 //prosedürdeki parametreler SqlParameter p1 = new SqlParameter("name", newPhoneCase.ProductName); SqlParameter p2 = new SqlParameter("price", newPhoneCase.Price); SqlParameter p3 = new SqlParameter("color", (int)newPhoneCase.CaseColor); SqlParameter p4 = new SqlParameter("qty", newPhoneCase.StockQTY); Program.SqlHelper.ExecuteProc("sp_CreatePhoneCase", p1, p2, p3, p4); #endregion }
public void PhoneCaseToProduct() { var id = Guid.NewGuid(); var lawnMower = new PhoneCase { Id = id, Name = "Extra sparkly", Price = 13.37, //FIXME: Prices REALLY should have been Decimal not Double... Colour = "Silver", Material = "Tungsten", TargetPhone = "Nexus 7" }; var product = lawnMower.ToProduct(); Assert.AreEqual(lawnMower.Id, product.Id, "ID mismatch!"); Assert.AreEqual(lawnMower.Name, product.Name, "Name mismatch!"); Assert.AreEqual(lawnMower.Price, product.Price, "Price mismatch!"); Assert.AreEqual("Phone Case", product.Type, "Type mismatch!"); }
private void InitialEnvironment() { _lawnmowerService = new Services.Implementation.LawnmowerService(_lawnmowerRepository.Object); //Set environment DontRefactor.Models.Lawnmower[] lawnmowerList = new DontRefactor.Models.Lawnmower[] { new DontRefactor.Models.Lawnmower() { Id = Guid.NewGuid(), Name = "Hewlett-Packard Rideable Lawnmower", FuelEfficiency = "Very Low", IsVehicle = true, Price = 3000.0 }, new DontRefactor.Models.Lawnmower() { Id = Guid.NewGuid(), Name = "Fisher Price's My First Lawnmower", FuelEfficiency = "Ultimate", IsVehicle = false, Price = 45.0 }, new DontRefactor.Models.Lawnmower() { Id = Guid.NewGuid(), Name = "Volkswagen LawnMaster 39000B Lawnmower", FuelEfficiency = "Moderate", IsVehicle = false, Price = 1020.0 } }; _lawnmowerRepository.Setup(l => l.GetAll()).Returns(lawnmowerList.AsQueryable()); _phoneCaseService = new Services.Implementation.PhoneCaseService(_phoneCaseRepository.Object); //Set environment DontRefactor.Models.PhoneCase[] phoneCaseList = new PhoneCase[] { new PhoneCase() { Id = Guid.NewGuid(), Name = "Amazon Fire Burgundy Phone Case", Colour = "Burgundy", Material = "PVC", TargetPhone = "Amazon Fire", Price = 14.0 }, new PhoneCase() { Id = Guid.NewGuid(), Name = "Nokia Lumia 920/930/Icon Crimson Phone Case", Colour = "Red", Material = "Rubber", TargetPhone = "Nokia Lumia 920/930/Icon", Price = 10.0 } }; _phoneCaseRepository.Setup(l => l.GetAll()).Returns(phoneCaseList.AsQueryable()); _tShirtService = new Services.Implementation.TShirtService(_tShirtRepository.Object); //Set environment DontRefactor.Models.TShirt[] tShirtList = new TShirt[] { new TShirt() { Id = Guid.NewGuid(), Colour = "Blue", Name = "Xamarin C# T-Shirt", Price = 15.0, ShirtText = "C#, Xamarin" }, new TShirt() { Id = Guid.NewGuid(), Colour = "Black", Name = "New York Yankees T-Shirt", Price = 8.0, ShirtText = "NY" }, new TShirt() { Id = Guid.NewGuid(), Colour = "Green", Name = "Disney Sleeping Beauty T-Shirt", Price = 10.0, ShirtText = "Mirror mirror on the wall..." } }; _tShirtRepository.Setup(l => l.GetAll()).Returns(tShirtList.AsQueryable()); _productService = new Services.Implementation.ProductService(_lawnmowerService, _phoneCaseService, _tShirtService); }