public void TestDemandView_AllowFinish() { DemandView view = new DemandView() { AllowFinish = false }; Assert.IsFalse(view.AllowFinish); view.AllowFinish = true; Assert.IsTrue(view.AllowFinish); }
public static Demand GetFittedRecord(this IEnumerable<Demand> demands, DemandView demandView) { return demands.FirstOrDefault( x => x.City.GetCityName() == demandView.City && x.ProjectName.Trim() == demandView.ProjectName.Trim() && x.ReceiveDate > demandView.ReceiveDate.AddDays(-1) && x.ReceiveDate < demandView.ReceiveDate.AddDays(1)); }
public void TestInitialize() { Initialize(); demandView = new DemandView { Id = 1, City = "广州", ProjectName = "project1", ReceiveDate = new DateTime(2013, 12, 12, 3, 0, 0) }; }
public void TestGetFittedDemandRecord_DemandView_ReceivedDateUnFit() { demandView = new DemandView { Id = 5, City = "佛山", ProjectName = "project2", ReceiveDate = new DateTime(2012, 12, 11, 4, 50, 0) }; Demand fittedDemand = demandList.GetFittedRecord(demandView); Assert.IsNull(fittedDemand); }
public void TestDemandView_ParseDemandParameters() { DemandView demandView = new DemandView() { DemandLevel = "B级", DemandSource = "政企客户", DemandType = "通信保障" }; Demand demand = Demand.Parse(demandView); Assert.AreEqual(demand.DemandLevel, DemandLevelDef.B); Assert.AreEqual(demand.DemandSource, DemandSourceDef.Government); Assert.AreEqual(demand.DemandType, DemandTypeDef.Communication); }
public void TestDemandView_BasicParameters() { DemandView demandView = new DemandView(); Assert.AreEqual(demandView.ExpectedSubscriber, 0); Assert.AreEqual(demandView.AcceptPath, "现场沟通"); Assert.AreEqual(demandView.CustomerLevel, "4"); Assert.AreEqual(demandView.DemandLevel, "C级"); Assert.AreEqual(demandView.DemandSource, "分公司"); Assert.AreEqual(demandView.DemandType, "内部投诉"); Assert.AreEqual(demandView.MarketingTheme, "营销渠道"); Assert.AreEqual(demandView.Satisfactory, "未知"); Assert.AreEqual(demandView.ProjectState, "跟进中"); }
public int SaveDemand(DemandView demand) { Demand objectDemand = Demands.GetFittedRecord(demand); if (objectDemand == null) { demand.Id = (demands.Count == 0) ? 1 : demands.Max(x => x.Id) + 1; demands.Add(Demand.Parse(demand)); } else { demand.Id = objectDemand.Id; objectDemand.CloneProperties(Demand.Parse(demand)); } return demand.Id; }
public void TestHomeControllerEdit_Post_ValidDemand_NotExisted() { demand = new DemandView { Id = 1, City = "广州", ProjectName = "project6", ReceiveDate = new DateTime(2013, 11, 11) }; Assert.AreEqual(repository.Demands.Count(), 5); ActionResult result = controller.Edit(demand); Assert.IsTrue(controller.ModelState.IsValid); Assert.AreEqual(controller.TempData["success"], "project6需求已成功保存!"); Assert.AreEqual(repository.Demands.Count(), 6); }
public void TestDemand_ParseMarketInfos() { DemandView demandView = new DemandView() { CustomerLevel = "2", MarketingTheme = "农村市场", Satisfactory = "满意", ProjectState = "完成" }; Demand demand = Demand.Parse(demandView); Assert.AreEqual(demand.CustomerLevel, CustomerLevelDef.Two); Assert.AreEqual(demand.MarketingTheme, MarketingThemeDef.Rural); Assert.AreEqual(demand.Satisfactory, SatisfactoryDef.Perfect); Assert.AreEqual(demand.ProjectState, ProjectStateDef.Complete); }
public void TestDemandView_ParseBasicParameters() { DemandView demandView = new DemandView() { ExpectedCompleteDate = new DateTime(2014, 6, 22), ExpectedProfit = 20000, ActualCompleteDate = new DateTime(2014, 7, 31), Department = "MarketDepartment" }; Demand demand = Demand.Parse(demandView); Assert.AreEqual(demand.ExpectedCompleteDate, new DateTime(2014, 6, 22)); Assert.AreEqual(demand.ExpectedProfit, 20000); Assert.AreEqual(demand.ActualCompleteDate, DateTime.Today.AddDays(-3)); Assert.AreEqual(demand.Department, "MarketDepartment"); }
public int SaveDemand(DemandView demand) { Demand objectDemand = Demands.GetFittedRecord(demand); int id; if (objectDemand == null) { id = context.Demands.Add(Demand.Parse(demand)).Id; } else { objectDemand.CloneProperties(Demand.Parse(demand)); id = objectDemand.Id; } context.SaveChanges(); return id; }
public void TestGetFittedDemandRecord_DemandView_Fit() { demandView = new DemandView { Id = 5, City = "佛山", ProjectName = "project2", ReceiveDate = new DateTime(2013, 12, 11, 4, 50, 0) }; Demand fittedDemand = demandList.GetFittedRecord(demandView); Assert.IsNotNull(fittedDemand); Assert.AreEqual(fittedDemand.Id, 2); demandView.ReceiveDate = new DateTime(2013, 12, 10, 0, 0, 4); fittedDemand = demandList.GetFittedRecord(demandView); Assert.IsNotNull(fittedDemand); Assert.AreEqual(fittedDemand.Id, 3); }
public ActionResult Edit(DemandView demand) { if (ModelState.IsValid) { int id = repository.SaveDemand(demand); int weekNum = (int)Math.Ceiling((DateTime.Now - new DateTime(DateTime.Now.Year, 1, 1)).Days / (float)7); progressRepository.SaveProgress(id, weekNum, demand.ProgressDescription); TempData["success"] = string.Format("{0}需求已成功保存!", demand.ProjectName); return RedirectToAction("Index"); } else { TempData["warning"] = "部分字段不合要求,请重新填写!"; return View(demand); } }