public void Initialize() { var context = new Mock<IContextAware>(); var view = new Mock<IProjectView>(); { view.SetupSet(v => v.Model = It.IsAny<ProjectModel>()) .Verifiable(); } var parameter = new ProjectParameter(context.Object); var projectLink = new Mock<ILinkToProjects>(); Func<string, IDisposable> func = s => new MockDisposable(); var command = new CloseProjectCommand(projectLink.Object, func); var container = new Mock<IDependencyInjectionProxy>(); { container.Setup(c => c.Resolve<IContextAware>()) .Returns(context.Object); container.Setup(c => c.Resolve<CloseProjectCommand>()) .Returns(command); } var presenter = new ProjectPresenter(container.Object); ((IPresenter)presenter).Initialize(view.Object, parameter); Assert.AreSame(view.Object, presenter.View); Assert.AreSame(parameter, presenter.Parameter); view.VerifySet(v => v.Model = It.IsAny<ProjectModel>(), Times.Once()); }
/// <summary> /// Constructor /// </summary> public MainVM() { connections = new ObservableCollection <ConnectionVM>(); ideaStatiCaDir = Properties.Settings.Default.IdeaStatiCaDir; if (Directory.Exists(ideaStatiCaDir)) { string ideaConnectionFileName = Path.Combine(ideaStatiCaDir, "IdeaConnection.exe"); if (File.Exists(ideaConnectionFileName)) { IsIdea = true; StatusMessage = string.Format("IdeaStatiCa installation was found in '{0}'", ideaStatiCaDir); CalcFactory = new ConnHiddenClientFactory(ideaStatiCaDir); } } if (!IsIdea) { StatusMessage = string.Format("ERROR IdeaStatiCa doesn't exist in '{0}'", ideaStatiCaDir); } OpenProjectCmd = new OpenProjectCommand(this); ImportIOMCmd = new ImportIOMCommand(this); CloseProjectCmd = new CloseProjectCommand(this); CalculateConnectionCmd = new CalculateConnectionCommand(this); ConnectionGeometryCmd = new ConnectionGeometryCommand(this); SaveAsProjectCmd = new SaveAsProjectCommand(this); ConnectionToTemplateCmd = new ConnectionToTemplateCommand(this); ApplyTemplateCmd = new ApplyTemplateCommand(this); }
public void Initialize() { var context = new Mock <IContextAware>(); var view = new Mock <IProjectView>(); { view.SetupSet(v => v.Model = It.IsAny <ProjectModel>()) .Verifiable(); } var parameter = new ProjectParameter(context.Object); var projectLink = new Mock <ILinkToProjects>(); Func <string, IDisposable> func = s => new MockDisposable(); var command = new CloseProjectCommand(projectLink.Object, func); var container = new Mock <IDependencyInjectionProxy>(); { container.Setup(c => c.Resolve <IContextAware>()) .Returns(context.Object); container.Setup(c => c.Resolve <CloseProjectCommand>()) .Returns(command); } var presenter = new ProjectPresenter(container.Object); ((IPresenter)presenter).Initialize(view.Object, parameter); Assert.AreSame(view.Object, presenter.View); Assert.AreSame(parameter, presenter.Parameter); view.VerifySet(v => v.Model = It.IsAny <ProjectModel>(), Times.Once()); }
/// <summary> /// Constructor /// </summary> public MainVM() { NewBoltAssemblyName = "M12 4.6"; SupportingMember = 1; AttachedMember = 2; connections = new ObservableCollection <ConnectionVM>(); ideaStatiCaDir = Properties.Settings.Default.IdeaStatiCaDir; if (Directory.Exists(ideaStatiCaDir)) { ideaConnExeFileName = Path.Combine(ideaStatiCaDir, "IdeaConnection.exe"); if (File.Exists(ideaConnExeFileName)) { IsIdea = true; StatusMessage = string.Format("IdeaStatiCa installation was found in '{0}'", ideaStatiCaDir); CalcFactory = new ConnHiddenClientFactory(ideaStatiCaDir); } } if (!IsIdea) { StatusMessage = string.Format("ERROR IdeaStatiCa doesn't exist in '{0}'", ideaStatiCaDir); } OpenProjectCmd = new OpenProjectCommand(this); ImportIOMCmd = new ImportIOMCommand(this); CloseProjectCmd = new CloseProjectCommand(this); CalculateConnectionCmd = new CalculateConnectionCommand(this); ApplySimpleTemplateCmd = new ApplySimpleTemplateCommand(this); ConnectionGeometryCmd = new ConnectionGeometryCommand(this); SaveAsProjectCmd = new SaveAsProjectCommand(this); ConnectionToTemplateCmd = new ConnectionToTemplateCommand(this); ApplyTemplateCmd = new ApplyTemplateCommand(this); GetMaterialsCmd = new GetMaterialsCommand(this); GetCrossSectionsCmd = new GetCrossSectionsCommand(this); GetBoltAssembliesCmd = new GetBoltAssembliesCommand(this); CreateBoltAssemblyCmd = new CreateBoltAssemblyCommand(this); GetParametersCmd = new GetParametersCommand(this); GetLoadingCmd = new GetLoadingCommand(this); GetConnCheckResultsCmd = new GetConnCheckResults(this); GetAllConnectionDataCmd = new GetAllConnDataCommand(this); ShowConHiddenCalcLogFileCmd = new ShowConHiddenCalcLogFileCommand(); OpenTempProjectCmd = new CustomCommand(CanRunIdeaConnection, RunIdeaConnection); ShowConHiddenCalcLogFileCmd = new ShowConHiddenCalcLogFileCommand(); TemplateSetting = new IdeaRS.OpenModel.Connection.ApplyConnTemplateSetting() { DefaultBoltAssemblyID = 1, DefaultCleatCrossSectionID = 1, DefaultConcreteMaterialID = 1, DefaultStiffMemberCrossSectionID = 1 }; jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(), Culture = CultureInfo.InvariantCulture }; var jsonFormating = Formatting.Indented; this.templateSettingString = JsonConvert.SerializeObject(TemplateSetting, jsonFormating, jsonSerializerSettings); }
public WorkPageViewModel() { WPOpenProjectCommand = new WPOpenProjectCommand(this); BeginStopWorkCommand = new BeginStopWorkCommand(this); CompleteTaskCommand = new CompleteTaskCommand(this); AddNoteCommand = new AddNoteCommand(this); ToggleNotesCommand = new ToggleNotesCommand(); CloseProjectCommand = new CloseProjectCommand(this); DeleteNoteCommand = new DeleteNoteCommand(); EditNoteCommand = new EditNoteCommand(this); }
public ProjectViewModel(UserInterface userInterface, StatusInfo statusInfo, OpenedProjects openedProjects, ProjectContext projectContext) { if (userInterface == null) { throw new ArgumentNullException(nameof(userInterface)); } if (statusInfo == null) { throw new ArgumentNullException(nameof(statusInfo)); } if (openedProjects == null) { throw new ArgumentNullException(nameof(openedProjects)); } if (projectContext == null) { throw new ArgumentNullException(nameof(projectContext)); } ProjectContext = projectContext; // Create view models. FlagListViewModel = new FlagListViewModel(projectContext, statusInfo, userInterface); MainFooterViewModel = new MainFooterViewModel(projectContext, statusInfo, userInterface); MainHeaderViewModel = new MainHeaderViewModel(projectContext, statusInfo, userInterface); // Create commands OpenAssemblyCommand = new OpenAssemblyCommand(userInterface, projectContext); CloseProjectCommand = new CloseProjectCommand(userInterface, openedProjects); // Initialize everything ProjectContext.Loaded += HandleProjectLoaded; ProjectContext.Unloaded += HandleProjectUnloaded; UpdateOpenPanelVisibility(); UpdateHeader(); }