public void Can_Check_Quality() { //Arrange IConditionChanger changer = new QualityBasedConditionChanger(); var qualityController = new QualityControl(); TestGlass goodQualityGlass = new TestGlass() { Quality = 100, Condition = "New" }; TestGlass brokenGlass = new TestGlass() { Quality = 15, Condition = "Broken" }; List <TestGlass> listOfGlassware = new List <TestGlass>() { goodQualityGlass, brokenGlass }; //Act qualityController.CheckQuality(goodQualityGlass); //Assert Assert.IsFalse(qualityController.QualityControlFailed); //Act qualityController.CheckQuality(brokenGlass); //Assert Assert.IsTrue(qualityController.QualityControlFailed); //Act qualityController.CheckQuality(listOfGlassware); //Assert Assert.IsTrue(qualityController.QualityControlFailed); }
static void Main(string[] args) { var mechanic = new Mechanic(); var detailer = new Detailer(); var wheels = new WheelSpecialist(); var qa = new QualityControl(); qa.SetNextServiceHandler(detailer); wheels.SetNextServiceHandler(qa); mechanic.SetNextServiceHandler(wheels); Console.WriteLine("Car 1 is dirty"); mechanic.Service(new Car { Requirements = ServiceRequirements.Dirty }); Console.WriteLine(); Console.WriteLine("Car 2 requires full service"); mechanic.Service(new Car { Requirements = ServiceRequirements.Dirty | ServiceRequirements.EngineTune | ServiceRequirements.TestDrive | ServiceRequirements.WheelAlignment }); Console.Read(); }
protected override void InitializeMockData() { _user = new User { UserId = GetGuid("1571"), UserName = "******" }; control = new QualityControl { Id = 1, Name = "Dimensional Control", Description = "Control dimensions DIM312 in CMM3", Instructions = new List <Instruction>(), Status = QualityControlStatus.Open }; desicions = new List <Desicion>() { new Desicion { Id = 1, Name = "Acepted" }, new Desicion { Id = 2, Name = "Rejected" }, new Desicion { Id = 3, Name = "Rework" } }; viewModel = new InspectionViewModel() { QualityControlId = 1, FinalDesicison = 1, Comments = "Compliant after dimensional control" }; }
public static void AddQualityControl(QualityControl qualitycontrol) { SqlConnection conn = new SqlConnection(ConnectionString); try { conn.Open(); SqlCommand cmd = new SqlCommand("AddQualityControl", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("Name", qualitycontrol.Name)); cmd.Parameters.Add(new SqlParameter("Description", qualitycontrol.Description)); cmd.Parameters.Add(new SqlParameter("Frequency", qualitycontrol.Frequency)); cmd.Parameters.Add(new SqlParameter("MinTol", qualitycontrol.MinTol)); cmd.Parameters.Add(new SqlParameter("MaxTol", qualitycontrol.MaxTol)); cmd.Parameters.Add(new SqlParameter("ProductOrderID", qualitycontrol.ProductOrder.ID)); cmd.Parameters.Add(new SqlParameter("MachineID", qualitycontrol.Machine.ID)); cmd.ExecuteNonQuery(); } catch (SqlException e) { MessageBox.Show(e.Message); } finally { conn.Close(); conn.Dispose(); } }
private void SetFlag(QualityControl flag, bool isChecked) { if (isChecked) controller.QualityControl = controller.QualityControl | flag; else controller.QualityControl = controller.QualityControl & ~flag; }
/// <summary> /// Creates a new qualityControl and saves to database /// </summary> /// <param name="name"></param> /// <param name="description"></param> /// <param name="frequency"></param> /// <param name="mintol"></param> /// <param name="maxtol"></param> /// <param name="machineIndex"></param> public void AddQualityControl(string name, string description, string frequency, string mintol, string maxtol, int machineIndex) { QualityControl qualitycontrol = new QualityControl(name, description, int.Parse(frequency), Convert.ToDecimal(mintol), Convert.ToDecimal(maxtol)); qualitycontrol.Machine = machines[machineIndex]; qualitycontrol.ProductOrder = machines[machineIndex].ProductOrder; DatabaseFacade.AddQualityControl(qualitycontrol); }
protected override void InitializeMockData() { desicion = new Desicion { Id = 1, Name = "Rejected" }; _mockControl = new QualityControl(_user) { Id = 1, Name = "High tolerances", Status = QualityControlStatus.Open, Defect = new Defect { Name = "DI110", Description = "Out of tolerances" }, Product = new Product { Name = "Blade", Description = "blade fb1" } }; controls = new List <QualityControl> { _mockControl, new QualityControl { Name = "Documental deviation", Description = "Prox p40", Product = new Product { Name = "CFM Fan Blade" }, Defect = new Defect { Name = "DEQ" }, Inspection = new Inspection { Desicion = desicion } } }; viewModel = new QualityControlViewModel { Name = "High tolerances", Description = "Dimensions DI310 and C220 out of upper tolerance.", Serial = "SN18972123", Defect = 1, Product = 1 }; detailViewModel = new QualityControlDetailViewModel { Id = 1, Name = "No-conforming dimensions", Description = "Dimension DI110 is out of upper tolerance." }; expectedRedirectValues = new RouteValueDictionary { { "action", "Index" }, { "controller", "QualityControl" } }; }
/// <summary> /// Updates a qualityControl /// </summary> /// <param name="index"></param> /// <param name="name"></param> /// <param name="description"></param> /// <param name="frequency"></param> /// <param name="mintol"></param> /// <param name="maxtol"></param> public void UpdateQualityControl(int index, string name, string description, int frequency, decimal mintol, decimal maxtol) { QualityControl qualitycontrol = qualitycontrols[index]; qualitycontrol.Name = name; qualitycontrol.Description = description; qualitycontrol.Frequency = frequency; qualitycontrol.MinTol = mintol; qualitycontrol.MaxTol = maxtol; DatabaseFacade.UpdateQualityControl(qualitycontrol); }
private void SetFlag(QualityControl flag, bool isChecked) { if (isChecked) { controller.QualityControl = controller.QualityControl | flag; } else { controller.QualityControl = controller.QualityControl & ~flag; } }
public async Task AddInstruction_NonExistingControl_ShouldReturnNotFound() { // Arrange QualityControl controlNull = null; _mockUnitOfWork.Setup(uw => uw.QualityControlRepository.FindByIdAsync(It.IsAny <int>())).Returns(Task.FromResult(controlNull)); // Act var result = await _controller.AddInstructionAsync(instructionDto); // Assert result.Should().BeOfType <NotFoundResult>(); }
public async Task AddInstructon_NonExistingControl() { //Arrange QualityControl controlNull = null; _mockRepository.Setup(r => r.FindByIdAsync(It.IsAny <int>())).Returns(Task.FromResult(controlNull)); //Act var result = await _controller.AddInstruction(viewModel) as HttpNotFoundResult; // Assert Assert.AreEqual(404, result.StatusCode); }
public async Task Update_NonExistingQualityControl() { // Arrange QualityControl controlNull = null; _mockUnitOfWork.Setup(uw => uw.QualityControlRepository.FindByIdAsync(It.IsAny <int>())) .Returns(Task.FromResult(controlNull)); // Act var result = await _controller.UpdateControl(detailViewModel) as HttpNotFoundResult; // Assert Assert.AreEqual(404, result.StatusCode); }
public async Task Inspect_NonExisting() { //Arrange QualityControl controlNullable = null; _mockRepository.Setup(r => r.GetWithDetailsAsync(It.IsAny <int>())).Returns(Task.FromResult(controlNullable)); //Act var result = await _controller.Inspect(viewModel) as HttpNotFoundResult; // Assert Assert.AreEqual(404, result.StatusCode); }
public async Task <ActionResult> Edit([Bind(Include = "Id,UserId,CreatedOn,CreatedBy,UpdatedOn,UpdatedBy,FirstName,LastName,Gender,MobilePhoneNumber,Email,Address,City")] QualityControl qualityControl) { if (ModelState.IsValid) { qualityControl.UpdatedBy = User.Identity.GetUserId(); qualityControl.UpdatedOn = DateTime.Now; _db.Entry(qualityControl).State = EntityState.Modified; await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(qualityControl)); }
public override void UpdateContent() { fLayoutPanel.Controls.Clear(); if (fModel == null) { return; } if (fAquarium != null) { fLayoutPanel.SuspendLayout(); fLayoutPanel.RowCount = 1; int col = 0, row = 0; var values = fModel.CollectData(fAquarium); foreach (var mVal in values) { if (!double.IsNaN(mVal.Value) && mVal.Ranges != null) { string title = mVal.Name; if (!string.IsNullOrEmpty(mVal.Unit)) { title += ", " + mVal.Unit; } var qCtl = new QualityControl(); qCtl.Margin = new Padding(LayoutPadding); qCtl.Dock = DockStyle.Top; qCtl.Anchor = AnchorStyles.Left; qCtl.Ranges = mVal.Ranges; qCtl.Value = mVal.Value; qCtl.Title = title; qCtl.Width = fLayoutPanel.ClientSize.Width - LayoutPadding * 2; fLayoutPanel.Controls.Add(qCtl, col, row); if (col == 0) { col += 1; } else { col = 0; row += 1; fLayoutPanel.RowCount += 1; } } } fLayoutPanel.ResumeLayout(); } }
public ListItemViewModel CreateViewModel(QualityControl control) { return(new ListItemViewModel { Id = control.Id, Name = control.Name, Description = control.Description, Status = GetDescription(control.Status), Product = control.Product.Name, Defect = control.Defect.Name, Desicion = control.Inspection != null ? control.Inspection.Desicion.Name : string.Empty }); }
public async Task Detail_SearchNonExistingControl() { //Arrange QualityControl controlNull = null; _mockUnitOfWork.Setup(uw => uw.QualityControlRepository .GetWithDetailsAsync(It.IsAny <int>())) .Returns(Task.FromResult(controlNull)); //Act var result = await _controller.UpdateControl(1); //Assert result.Should().BeOfType <HttpNotFoundResult>(); }
// GET: QualityControls/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QualityControl qualityControl = await _db.QualityControls.FindAsync(id); if (qualityControl == null) { return(HttpNotFound()); } return(View(qualityControl)); }
public async Task GetInstructionByControl_ShouldNotFoundResult() { //Arrange QualityControl controlNull = null; _mockUnitOfWork.Setup(uw => uw.QualityControlRepository .GetWithDetailsAsync(It.IsAny <int>())) .Returns(Task.FromResult(controlNull)); //Act var result = await _controller.GetByProduct(1); //Assert result.Should().BeOfType <NotFoundResult>(); }
public async Task <ActionResult> DeleteConfirmed(int id) { QualityControl qualityControl = await _db.QualityControls.FindAsync(id); var existingUser = await UserManager.FindByNameAsync(qualityControl.Email); if (existingUser != null) { //string sExistingId = existingUser.Id; //ViewBag.Message = "Email Already Exists: " + sExistingId + "! Liaison Portal Not Created!."; await UserManager.DeleteAsync(existingUser); } _db.QualityControls.Remove(qualityControl); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); }
protected override void InitializeMockData() { control = new QualityControl { Id = 1, Name = "Dimensional Control", Description = "Control dimensions DIM312 in CMM3", Instructions = new List <Instruction>(), Status = QualityControlStatus.Open }; viewModel = new InstructionViewModel { QualityControlId = 1, Name = "CMM", Description = "Control dimension DI312", Comments = "N/A" }; }
protected override void InitializeMockData() { dto = new QualityControlDto { Id = 1, Name = "High tolerances", Description = "Dimensions DI310 and C220 out of upper tolerance.", Serial = "SN18972123", Defect = 1, Product = 1 }; control = new QualityControl(_user) { Id = 1, Name = "High tolerances", Description = "Dimensions DI310 and C220 out of upper tolerance.", Defect = new Defect { Name = "Scratch" }, Product = new Product { Name = "Blade F23" }, Instructions = new List <Instruction>(), Status = QualityControlStatus.InProgress }; secondControl = new QualityControl { Name = "MPI", Description = "Scratch in zone D3", Defect = new Defect { Name = "Scratch" }, Product = new Product { Name = "Blade F23" }, Status = QualityControlStatus.Open }; controls = new List <QualityControl>() { control, secondControl }; }
protected override void InitializeMockData() { desicion = new Desicion { Id = 1, Name = "Acepted" }; inspection = new InspectionDto { QualityControlId = 1, Comments = "Instructions' results OK", Desicion = 1 }; control = new QualityControl { Name = "High tolerances", Defect = new Defect { Name = "Dimensional" }, Status = QualityControlStatus.Open }; }
public ActionResult CustomBinding(GridViewModel model) { var co = CriteriaOperator.Parse(model.FilterExpression); string criterias = CriteriaToWhereClauseHelper.GetMsSqlWhere(co, true); var sortOptions = model.SortedColumns.Select(c => new SortOption { Field = c.FieldName, SortIndex = c.SortIndex, SortOrder = c.SortOrder.ToString() }); var page = QualityControl.GetMeasurementsPage( model.Pager.PageIndex, model.Pager.PageSize, criterias, sortOptions); model.ProcessCustomBinding( e => e.DataRowCount = page.TotalItems, e => e.Data = page.Items); return(PartialView("_ContactsGridView", model)); }
protected override void InitializeMockData() { instructionDto = new InstructionDto { Name = "Dimensional Control", Description = "Control Dimensions DI010 and DI0320", QualityControlId = 1 }; instruction = new Instruction { Id = 1, Name = "CMM Control", Description = "remeasure DI010 and DI0320", QualityControlId = 1, Status = InstructionStatus.Performed }; secondInstruction = new Instruction { Id = 1, Name = "Shipping", Description = "Shipping Product", QualityControlId = 1, Status = InstructionStatus.Pending }; control = new QualityControl { Id = 1, Name = "High tolerances", Defect = new Defect { Name = "Dimensional" }, Status = QualityControlStatus.Open, Instructions = new List <Instruction>() { instruction, secondInstruction } }; instruction.QualityControl = control; }
public async Task <ActionResult> Create([Bind(Include = "Id,UserId,CreatedOn,CreatedBy,UpdatedOn,UpdatedBy,FirstName,LastName,Gender,MobilePhoneNumber,Email,Address,City")] QualityControl qualityControl) { if (ModelState.IsValid) { var existingUser = await UserManager.FindByNameAsync(qualityControl.Email); if (existingUser != null) { string sExistingId = existingUser.Id; ViewBag.Message = "Email Already Exists: " + qualityControl.Email + "! Liaison Portal Not Created!."; return(View(qualityControl)); // await UserManager.DeleteAsync(existingUser); } ApplicationUser user = new ApplicationUser { UserName = qualityControl.Email, Email = qualityControl.Email, FirstName = qualityControl.FirstName, LastName = qualityControl.LastName, Role = "QAQC" }; string password = qualityControl.LastName.ToLower() + "#QAQC1013"; // + liaisonId; var result = await UserManager.CreateAsync(user, password); if (result.Succeeded) { await UserManager.AddToRoleAsync(user.Id, "QAQC"); qualityControl.UserId = user.Id; qualityControl.CreatedOn = DateTime.Now; qualityControl.CreatedBy = User.Identity.GetUserId(); } _db.QualityControls.Add(qualityControl); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(qualityControl)); }
public QualityControlDetailViewModel Create(QualityControl control) { return(new QualityControlDetailViewModel { Id = control.Id, Serial = control.Serial, Name = control.Name, Description = control.Description, Status = GetDescription(control.Status), Defect = control.Defect.Name, DefectDescription = control.Defect.Description, Product = control.Product.Name, ProductDescription = control.Product.Description, LastModificationDate = control.LastModificationDate.ToString(), CreateDate = control.CreateDate.ToString(), UserCreated = control.UserCreated.UserName, LastModificationUser = control.LastModificationUser.UserName, CanSave = !control.Instructions .Any(i => i.Status == InstructionStatus.Pending) && control.Status != QualityControlStatus.Closed ? true : false }); }
public void Ongo() { try { TaskInfoDialog = TaskInfoDialogViewModel.getInstance(); //TaskInfoDialog.Messages.Add("开始质检项目:" + Project.ProjectName); TaskMessage taskMessage = new TaskMessage(); taskMessage.Title = "质检项目:" + Project.ProjectName; taskMessage.Progress = 0.0; TaskInfoDialog.Messages.Insert(0, taskMessage); Task task = new Task(() => { //Thread.Sleep(2000); QualityControl qualityControl = new QualityControl(); qualityControl.Project = ProjectDal.InitialRealEstateProject(Project); qualityControl.TaskMessage = taskMessage; try { ErrorMsg.AddRange(qualityControl.Check()); } catch (Exception ex) { ErrorMsg.Add(ex.Message); } }); task.Start(); task.ContinueWith(t => { ThreadPool.QueueUserWorkItem(delegate { SynchronizationContext.SetSynchronizationContext(new System.Windows.Threading.DispatcherSynchronizationContext(System.Windows.Application.Current.Dispatcher)); SynchronizationContext.Current.Post(pl => { foreach (var error in ErrorMsg) { taskMessage.DetailMessages.Add(error); } if (ErrorMsg != null && ErrorMsg.Count > 0) { taskMessage.DetailMessages.Add("质检不通过"); Project.State = "0"; Project.UptateTime = DateTime.Now; ProjectDal.Modify(Project); } else { taskMessage.DetailMessages.Add("质检合格"); Project.State = "1"; Project.UptateTime = DateTime.Now; ProjectDal.Modify(Project); } }, null); }); }); } catch (Exception ex) { throw ex; } }