public void TestJointNewEdit() { var modifiableView = new Mock <IModifiable>(); var notify = new Mock <IUserNotify>(); var repoJoint = new Mock <IJointRepository>(); var repoJointTestResult = new Mock <IJointTestResultRepository>(); var repoJointWeldResult = new Mock <IJointWeldResultRepository>(); var repoJointOperation = new Mock <IJointOperationRepository>(); var repoInspector = new Mock <IInspectorRepository>(); var repoWelder = new Mock <IWelderRepository>(); var repoAdo = new Mock <IMillReportsRepository>(); var securityCtx = new Mock <ISecurityContext>(); var repoSpool = new Mock <ISpoolRepository>(); var repoPipe = new Mock <IPipeRepository>(); var repoComponent = new Mock <IComponentRepository>(); var joint = new Prizm.Domain.Entity.Construction.Joint() { Status = Domain.Entity.Construction.JointStatus.Withdrawn }; BindingList <JointOperation> operations = new BindingList <JointOperation>(); Mock <IConstructionRepository> repoConstruction = new Mock <IConstructionRepository>(); repoConstruction.SetupGet(_ => _.RepoJoint).Returns(repoJoint.Object); repoConstruction.SetupGet(_ => _.RepoJointTestResult).Returns(repoJointTestResult.Object); repoConstruction.SetupGet(_ => _.RepoJointWeldResult).Returns(repoJointWeldResult.Object); repoConstruction.SetupGet(_ => _.RepoJointOperation).Returns(repoJointOperation.Object); repoConstruction.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object); repoConstruction.SetupGet(_ => _.RepoWelder).Returns(repoWelder.Object); repoConstruction.SetupGet(_ => _.RepoSpool).Returns(repoSpool.Object); repoConstruction.SetupGet(_ => _.RepoPipe).Returns(repoPipe.Object); repoConstruction.SetupGet(_ => _.RepoComponent).Returns(repoComponent.Object); repoJointOperation.Setup(_ => _.GetControlOperations()).Returns(operations); repoJointOperation.Setup(_ => _.GetRepairOperations()).Returns(operations); repoJoint.Setup(_ => _.GetActiveByNumber(joint)).Returns(new List <Prizm.Domain.Entity.Construction.Joint>()); repoSpool.Setup(_ => _.Get(It.IsAny <Guid>())).Returns(new Domain.Entity.Construction.Spool()); modifiableView.SetupGet(x => x.IsModified).Returns(false); var viewModel = new JointNewEditViewModel(repoConstruction.Object, notify.Object, Guid.Empty, repoAdo.Object, securityCtx.Object); viewModel.Joint = joint; viewModel.FirstElement = new PartData(); viewModel.SecondElement = new PartData(); viewModel.ModifiableView = modifiableView.Object; var validatable = new Mock <IValidatable>(); validatable.Setup(x => x.Validate()).Returns(true); viewModel.ValidatableView = validatable.Object; var command = new SaveJointCommand(repoConstruction.Object, viewModel, notify.Object, securityCtx.Object); command.Execute(); repoConstruction.Verify(_ => _.BeginTransaction(), Times.Once()); repoJoint.Verify(_ => _.SaveOrUpdate(It.IsAny <Prizm.Domain.Entity.Construction.Joint>()), Times.Once()); repoConstruction.Verify(_ => _.Commit(), Times.Once()); repoJoint.Verify(_ => _.Evict(It.IsAny <Prizm.Domain.Entity.Construction.Joint>()), Times.Once()); }
public JointDeactivationCommand(IConstructionRepository repo, JointNewEditViewModel viewModel, IUserNotify notify, ISecurityContext ctx) { this.repo = repo; this.viewModel = viewModel; this.notify = notify; this.ctx = ctx; }
public JointCutCommand( IConstructionRepository repo, JointNewEditViewModel viewModel, IUserNotify notify) { this.repo = repo; this.viewModel = viewModel; this.notify = notify; }
public void SetupForm(IList<construction.Joint> joints, JointNewEditViewModel viewModel) { BindingList<construction.Joint> bindingList = new BindingList<construction.Joint>(joints); this.joints = bindingList; this.viewModel = viewModel; }
public JointSelectDialog(IList<construction.Joint> joints, JointNewEditViewModel viewModel) { InitializeComponent(); SetupForm(joints, viewModel); }
private void JointNewEditXtraForm_FormClosed(object sender, FormClosedEventArgs e) { commandManager.Dispose(); viewModel.Dispose(); viewModel = null; }
public JointNewEditXtraForm(Guid id) { this.Id = id; InitializeComponent(); SetControlsTextLength(); viewModel = (JointNewEditViewModel)Program .Kernel .Get<JointNewEditViewModel>( new ConstructorArgument("id", id)); viewModel.ModifiableView = this; viewModel.ValidatableView = this; loweringDate.Properties.NullText = String.Empty; loweringDate.Properties.NullDate = DateTime.MinValue; CannotOpenForViewing = id == Guid.Empty; #region --- Colouring of required controls, IsEditMode, uppercasing, digits befor decimal point --- jointNumber.SetRequiredText(); SetAlwaysReadOnly(jointStatus); firstJointElement.SetRequiredText(); secondJointElement.SetRequiredText(); jointNumber.SetAsIdentifier(); searchNumber.SetAsIdentifier(); firstJointElement.SetAsLookUpIdentifier(); secondJointElement.SetAsLookUpIdentifier(); distanceFromPK.SetFloatMask(Constants.DigitsBeforeDecimalPoint); GPSLat.SetGPSMaskLatitude(Constants.DigitsAfterDecimalPointForGPS, Constants.MaxLatitude); GPSLong.SetGPSMaskLongitude(Constants.DigitsAfterDecimalPointForGPS, Constants.MaxLongitude); seaLevel.SetFloatMask(Constants.DigitsBeforeDecimalPoint, canBeNegative:true); attachmentsButton.Enabled = true; SetConditional(jointNumber, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(firstJointElement, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(secondJointElement, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(secondJointElement, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(controlOperations, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(loweringDate, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(PKNumber, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(distanceFromPK, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(GPSLat, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(GPSLong, delegate(bool editMode) { return (viewModel.JointIsActive); }); SetConditional(seaLevel, delegate(bool editMode) { return (viewModel.JointIsActive); }); #endregion }
public QuickSearchCommand(JointNewEditViewModel vm, IJointRepository repo, IUserNotify notify) { viewModel = vm; this.repo = repo; this.notify = notify; }
public void TestJointNewEdit() { var modifiableView = new Mock<IModifiable>(); var notify = new Mock<IUserNotify>(); var repoJoint = new Mock<IJointRepository>(); var repoJointTestResult = new Mock<IJointTestResultRepository>(); var repoJointWeldResult = new Mock<IJointWeldResultRepository>(); var repoJointOperation = new Mock< IJointOperationRepository>(); var repoInspector = new Mock<IInspectorRepository>(); var repoWelder = new Mock<IWelderRepository>(); var repoAdo = new Mock<IMillReportsRepository>(); var securityCtx = new Mock<ISecurityContext>(); var repoSpool = new Mock<ISpoolRepository>(); var repoPipe = new Mock<IPipeRepository>(); var repoComponent = new Mock<IComponentRepository>(); var joint = new Prizm.Domain.Entity.Construction.Joint() { Status = Domain.Entity.Construction.JointStatus.Withdrawn}; BindingList<JointOperation> operations = new BindingList<JointOperation>(); Mock<IConstructionRepository> repoConstruction = new Mock<IConstructionRepository>(); repoConstruction.SetupGet(_ => _.RepoJoint).Returns(repoJoint.Object); repoConstruction.SetupGet(_ => _.RepoJointTestResult).Returns(repoJointTestResult.Object); repoConstruction.SetupGet(_ => _.RepoJointWeldResult).Returns(repoJointWeldResult.Object); repoConstruction.SetupGet(_ => _.RepoJointOperation).Returns(repoJointOperation.Object); repoConstruction.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object); repoConstruction.SetupGet(_ => _.RepoWelder).Returns(repoWelder.Object); repoConstruction.SetupGet(_ => _.RepoSpool).Returns(repoSpool.Object); repoConstruction.SetupGet(_ => _.RepoPipe).Returns(repoPipe.Object); repoConstruction.SetupGet(_ => _.RepoComponent).Returns(repoComponent.Object); repoJointOperation.Setup(_ => _.GetControlOperations()).Returns(operations); repoJointOperation.Setup(_ => _.GetRepairOperations()).Returns(operations); repoJoint.Setup(_ => _.GetActiveByNumber(joint)).Returns(new List<Prizm.Domain.Entity.Construction.Joint>()); repoSpool.Setup(_ => _.Get(It.IsAny<Guid>())).Returns(new Domain.Entity.Construction.Spool()); repoAdo.Setup(x => x.GetPipelineElements()).Returns(new System.Data.DataTable()); modifiableView.SetupGet(x => x.IsModified).Returns(false); var viewModel = new JointNewEditViewModel(repoConstruction.Object, notify.Object, Guid.Empty, repoAdo.Object, securityCtx.Object); viewModel.Joint = joint; viewModel.FirstElement = new PartData(); viewModel.SecondElement = new PartData(); viewModel.ModifiableView = modifiableView.Object; var validatable = new Mock<IValidatable>(); validatable.Setup(x => x.Validate()).Returns(true); viewModel.ValidatableView = validatable.Object; viewModel.Joint.LoweringDate = DateTime.Now; viewModel.Joint.Number = string.Empty; var welder = new Welder(); var weldResult = new JointWeldResult(); weldResult.Welders.Add(welder); weldResult.IsCompleted = true; viewModel.JointWeldResults.Add(weldResult); var command = new SaveJointCommand(repoConstruction.Object,viewModel, notify.Object, securityCtx.Object); command.Execute(); repoConstruction.Verify(_ => _.BeginTransaction(), Times.Once()); repoJoint.Verify(_ => _.SaveOrUpdate(It.IsAny<Prizm.Domain.Entity.Construction.Joint>()), Times.Once()); repoConstruction.Verify(_ => _.Commit(), Times.Once()); repoJoint.Verify(_ => _.Evict(It.IsAny<Prizm.Domain.Entity.Construction.Joint>()), Times.Once()); }